jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.49k stars 332 forks source link

Date Time format from System #378

Closed snagytx closed 1 year ago

snagytx commented 1 year ago

Hello,

Is it possible to add date/time fields with the format getting pulled from the system? I don't want to set the format manually, I just want to mark the field as date/time field.

The date/time fields should be updated automatically when opened in different system date/format settings. Us us MM/DD/YYYY while EU is DD/MM/YYYY.

Thanks.

jmcnamara commented 1 year ago

The date/time fields should be updated automatically when opened in different system date/format settings. Us us MM/DD/YYYY while EU is DD/MM/YYYY.

Excel has some built in formats that change with the system:

Screenshot 2022-09-23 at 15 36 03

You can enable these with libxlsxwriter using the format_set_num_format_index() function:

      format = workbook_add_format(workbook);
      format_set_num_format_index(format, 14); // m/d/yy
snagytx commented 1 year ago

Yes, I was about to test using format_set_num_format_index