salvois / LargeXlsx

A .net library to write large Excel files in XLSX format with low memory consumption using streamed write.
Other
204 stars 34 forks source link

Q&A : DateTime format column #27

Closed httt-dev closed 1 year ago

httt-dev commented 1 year ago

I want to use LargeXlsx 1.7.3 to write large data. I also want format datetime column look like "yyyy/MM/dd HH:mm:ss" , how to format it ? Thanks

dgosbell commented 1 year ago

You can do this by passing a style with a custom format to the overload of the Write method xlsxWriter.Write( dt , XlsxStyle.Default.With(new XlsxNumberFormat("yyyy/mm/dd\ hh:mm:ss")));

salvois commented 1 year ago

Hello @httt-dev , as @dgosbell said (thanks!), you just need to create, even on the fly, your own style with the very same number format you would write in Excel to format your date. Thanks, Salvo

httt-dev commented 1 year ago

The problem was resolved.Thanks you very much @dgosbell @salvois