sheet_to_json function changes original date format #2756

Open
opened 2022-08-04 08:46:37 +00:00 by hhllee · 1 comment
hhllee commented 2022-08-04 08:46:37 +00:00 (Migrated from github.com)

A user uploads an xlsx document, and one of the columns is a date, and it's displayed as "2022/7/21"
but when sheet_to_json read the xlsx, the data formats will change like this
image
How to resolve this problem
Thanks

xlsx: ^0.18.5

A user uploads an xlsx document, and one of the columns is a date, and it's displayed as "2022/7/21" but when sheet_to_json read the xlsx, the data formats will change like this ![image](https://user-images.githubusercontent.com/57935206/182803782-060929d1-f6e5-48bd-b1cd-45315228bfc7.png) How to resolve this problem Thanks xlsx: ^0.18.5
SheetJSDev commented 2022-09-13 18:09:42 +00:00 (Migrated from github.com)

https://docs.sheetjs.com/docs/csf/features/dates#how-files-store-dates-and-times

The file itself may be using the magical format m/d/yy (which is interpreted in different ways depending on the locale).

If you want to reformat the dates, pass the option cellDates: true to generate date objects, delete the w fields for date cells and replace them with the format of your choice.

At some point we will offer a more general solution

https://docs.sheetjs.com/docs/csf/features/dates#how-files-store-dates-and-times The file itself may be using the magical format `m/d/yy` (which is interpreted in different ways depending on the locale). If you want to reformat the dates, pass the option `cellDates: true` to generate date objects, delete the `w` fields for date cells and replace them with the format of your choice. At some point we will offer a more general solution
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
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: sheetjs/sheetjs#2756
No description provided.