ClosedXML / ClosedXML/ClosedXML.Report

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

Open
#384 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
647
Forks
122
PR merge metrics
No merged PRs in 30d

Description

![Image](https://github.com/user-attachments/assets/f5736d00-7c82-43e5-b6d2-37318ac97ce8)

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.

```csharp
// FormattingTest
// Bug Date Format not working: [$-de-DE]TTT, TT
var table5 = new List
{
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](https://github.com/user-attachments/files/19320620/FormattingTest.xlsx)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.