sheet_to_json function changes original date format #2756

Open
opened 6 months ago by hhllee · 1 comments
hhllee commented 6 months ago (Migrated from github.com)
Owner

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 5 months ago (Migrated from github.com)
Owner

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 project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2756
Loading…
There is no content yet.