Closed hanric2 closed 5 years ago
Hello, You can use for this particular use case the NumberFormat property 22. This is a subsection of the styles (dates are formatted a little bit weird):
Style style = new Style();
style.CurrentNumberFormat.Number = Style.NumberFormat.FormatNumber.format_22;
workbook.CurrentWorksheet.AddNextCell(DateTime.Now, style);
Be aware, that this formatting may be deviating, based on the locale (date, time and number formats of several countries) of the computer that opens the file in Excel.
You find a collection of all embedded NumberFormat styles here: https://rabanti-github.github.io/PicoXLSX/html/551f78ab-758c-cbe9-8e7c-1cef0a87f040.htm
If you want to define a special format, you can still use NumberFormat, but you have to define a custom style. To figure out the format string, you can define the custom formt in excel and look it up with a tool like MediaExtractor.
Can you work with this?
Thank you.
How to define cell style to datetime format "dd.mm.yyyy hh:mm" ? Thanks for answer.