I’m using Aspose.Cells for Java with the following code to export an Excel document to CSV:
Workbook workbook = new Workbook("C:\\in.xlxs");
workbook.save("C:\\out.csv", com.aspose.cells.SaveFormat.CSV);
Depending on the runtime environment the date/time is exported in different formats e.g.: “12/27/2021 09:00:00 PM” or “27.12.2021 21:00:00”
How can I export date/time fields always in the iso 8601 format (yyyy-MM-dd HH:mm:ss) such that date fields are exported as e.g. “2021-12-27 21:00:00”?
@martin.duerig,
This is expected behavior. This is same with MS Excel. If you specify numbers formattings for data in MS Excel, this will be changed in accordance with locale/regional setting of the machine where you open the file into MS Excel (manually).
To achieve your desired output formatting, you may set custom formatting (“yyyy-MM-dd HH:mm:ss”) for your desired cells and then render to CSV, it will work. Please note, when you specify the custom numbers formatting for the cells data, the formatting will be independent/constant irrespective of the locale/regional settings.