EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

DateOnly Not Fully Supported as a Proper Sortable Date

Open pbarranis opened this issue 8 months ago • 2 comments

EPPlus usage

Noncommercial use

Environment

Windows 10+

Epplus version

7.2.0

Spreadsheet application

Microsoft Excel

Description

When I set the Value of a cell in code to a DateTime, then view it in Excel, I see something like "43980" unless I apply formatting, but if I set the Value of a cell to a DateOnly, then view it in Excel, I see something like "5/9/2020". The former can be formatted in Excel as a Date and sorted ASC/DSC properly; the latter is treated as text by Excel and will not allow me to format it or sort it properly.

I believe this is because under the hood EPPlus automatically converts the DateTime using ToOADate when setting the raw value in the XML, and I think to properly support DateOnly the same needs to be done for that type too.

I am not using TimeOnly in my code, but it's worth noting that the same issue probably exists for that type too.

If I'm right, then there really shouldn't be any further info required here; this would be a fairly quick change to your type conversion code, I hope. Please let me know if you cannot repro with this limited info.

This might be more correctly labeled as a feature request and not a bug. If so, I'm sorry for calling it a bug.

pbarranis avatar Jun 19 '24 02:06 pbarranis