Read excel when contains date format data #3107
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#3107
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I was trying to read excel data as json by calling XLSX.read. And there are columns using Date format. (which may using 1900 date system stored the date as number).
I'm calling
read
function by settingcellDates: true
. Getting this kind of bug:TimeZone: China Time
Excel File:
https://docs.sheetjs.com/DateTime.xlsx
Parsed Result:
There is '43s' missing here. Looks like this is because excel is using 1900 date system, and there is a time zone change from 805 to 8 for China. And looks like
cellDates: true
does not handle it in a right way.excel files errorto Read excel when contains date format dataUsing version 0.20.2, in the
Asia/Shanghai
timezone, you should seeDate and DateTime will be correct since they are after the timezone shift.
The Time is incorrect since that happened before the shift.
The issue here is a mismatch between how JavaScript and Excel dates work. https://docs.sheetjs.com/docs/csf/features/dates
Any sort of mapping between Excel and JavaScript concepts will have unexpected conversions (breaking UTC interpretation and/or local interpretation and/or differences between times).
If you want to force UTC interpretation, pass the option
UTC: true
tosheet_to_json
(https://docs.sheetjs.com/docs/api/utilities/array/#array-output)To verify this, in Linux or macOS, you can set the
TZ
environment variable to force timezone:The result will be