Open jaimyjaimy opened 1 year ago
Please try to change FormatCode
to "mm-dd-yy"
also, recommend trying the Cell
class, it usually significantly simplify the code
https://github.com/sergey-tihon/Clippit/blob/master/OpenXmlPowerTools/Excel/Cell.cs
Unfortunately the date format is not picked by me, but it is flexible based on what the customer wants. dd-MM-yyyy is what this customer wanted.
Then you have to dig into OpenXML spec format. (FormatCode
is not .NET DateTime format)
formatCode (Format Code) This element specifies a string representing the format code to apply. For more information see the SpreadsheetML numFmt element's (§18.8.30) formatCode attribute.
here is the spec https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oi29500/17d11129-219b-4e2c-88db-45844d21e528
I am creating 2 worksheets, the first sheet has some information in string format, the second sheet has a datetime in it.
Excel gives an error if create the sheet with string format first and the datetime second. If I turn around the order, so datetime sheet first and then string format second, it won't give an error.
Below is the C# code I used. (I used Clippit 1.13.5 also tried it on 1.4 and 1.5 and 1.7)