ClosedXML.Report icon indicating copy to clipboard operation
ClosedXML.Report copied to clipboard

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

Open Bush-cat opened this issue 7 months ago • 3 comments

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

Bush-cat avatar Mar 18 '25 14:03 Bush-cat