[GH-ISSUE #378] Date Time format from System #302

Closed
opened 2026-05-05 12:07:29 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @snagytx on GitHub (Sep 23, 2022).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/378

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.

Originally created by @snagytx on GitHub (Sep 23, 2022). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/378 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.
Author
Owner

@jmcnamara commented on GitHub (Sep 23, 2022):

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
<!-- gh-comment-id:1256393726 --> @jmcnamara commented on GitHub (Sep 23, 2022): > 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](https://user-images.githubusercontent.com/94267/192002872-e12198ae-bd0c-425d-9924-b8370646b126.png) You can enable these with libxlsxwriter using the [`format_set_num_format_index()`](http://libxlsxwriter.github.io/format_8h.html#a688aa42bcc703d17e125d9a34c721872) function: ```C format = workbook_add_format(workbook); format_set_num_format_index(format, 14); // m/d/yy ```
Author
Owner

@snagytx commented on GitHub (Sep 23, 2022):

Yes, I was about to test using format_set_num_format_index

<!-- gh-comment-id:1256396244 --> @snagytx commented on GitHub (Sep 23, 2022): Yes, I was about to test using `format_set_num_format_index`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#302
No description provided.