SheetJS / sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs

Home Page:https://sheetjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sheet_to_json function changes original date format

hhllee opened this issue · comments

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

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

let WorkSheet= { [SheetName]: XLSX.utils.sheet_to_json(WorkBook.Sheets[SheetName], { raw: false, }), };

i find those problem to last time, so i just add option raw: false

My problem is: XLSX.utils.sheet_to_json
hexcel header is: radif date time bank kind amount refno sharh more to rest channel 1 2
body data write:1 2 radif date time bank kind amount refno sharh more to rest channel
why?