Skip to content

Date Format is not applied until manually entering Cell when using DateOnly #384

@Bush-cat

Description

@Bush-cat

Image

I often had it that the custom Format did not get applied to ClosedXML.Report outputs and I always had to manually enter cells for them to apply. Even default Date Formats were not applied unitl you entered the Cell. I made a Sample which shows the behaviour in ClosedXML.Report 0.2.12-rc, (also behaved the same in old 0.2.2). I only have one Template where I got it working without manually doing so, but I was not able to replicate it.

// FormattingTest
// Bug Date Format not working: [$-de-DE]TTT, TT
var table5 = new List<FormattingTestEntry>
{
    new("TestName6", new DateOnly(2025, 3, 23)),
    new("TestName7", new DateOnly(2025, 3, 24)),
    new("TestName8", new DateOnly(2025, 3, 25)),
    new("TestName9", new DateOnly(2025, 3, 26))
};

template.AddVariable("FormattingTest", table5);

template.Generate();
template.SaveAs(outputFile);

private record FormattingTestEntry(
    string Name,
    DateOnly Date
);

FormattingTest.xlsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions