reading with option `cellDates: true` has wrong date values if original cell date was before 26th march 2018
See original GitHub issueif cells with date value have an date before 03/25/2018
and loading xlsx file with option cellDates: true
the loaded cells in worksheet are one day earlier than original date value.
it(‘with option cellDates: true
XLSX should parse date correctly’, function() {
var wb = X.read(
fs.readFileSync(‘./test_files-bug-report/check-date-bug.xlsx’),
{cellDates: true, type: TYPE}
);
var ws = wb.Sheets[‘check-date-bug’];
assert(dateToString(ws.B46.v) === ‘2018-6-5’); // work
assert(dateToString(ws.B37.v) === ‘2018-3-27’); // work
assert(dateToString(ws.B36.v) === ‘2018-3-26’); // work
assert(dateToString(ws.B35.v) === ‘2018-3-25’); // fail: ‘2018-3-24’
assert(dateToString(ws.B34.v) === ‘2018-3-24’); // fail: ‘2018-3-23’
assert(dateToString(ws.B3.v) === ‘2015-1-1’); // fail: ‘2014-12-31’
assert(dateToString(ws.B2.v) === ‘2014-1-1’); // fail: ‘2013-12-31’
});
There is a fork with added test that currently fail: fork-branch: https://github.com/pluederitz/js-xlsx/tree/bug-date-parsing-cell-dates-true added test: https://github.com/pluederitz/js-xlsx/blob/bug-date-parsing-cell-dates-true/test.js#L384-L410 added xlsx file: https://github.com/pluederitz/js-xlsx/blob/bug-date-parsing-cell-dates-true/test_files-bug-report/check-date-bug.xlsx
to check bug run added test:
git clone https://github.com/pluederitz/js-xlsx.git checkout bug-date-parsing-cell-dates-true npm install make ctestserv open browser on http://127.0.0.1:8000
2nd suite “bug-reports” contains test “with option cellDates: true
XLSX should parse date correctly (also date before 26th of march 2018)”
added bug test also fail on running tests under node.js
npm test
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:11 (1 by maintainers)
Top GitHub Comments
I had the same issue, and ended up parsing it on my own:
This is based on a Stackoverflow answer: https://stackoverflow.com/a/22352911/11599033
Workaround: use SSF library to convert raw excel number dates.