-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
🐛 Bug Report
Dates are not being parsed correctly when using streaming - issue seems to be the parser internally not getting the "style" for the field.
Lib version: 4.1.1 (latest)
Steps To Reproduce
const through = require('through2')
const { pipeline, Readable } = require('readable-stream')
const reader = new Excel.stream.xlsx.WorkbookReader(fs.createReadStream('file.xlsx'))
const createReader = async function* () {
for await (const worksheet of reader) {
for await (const row of worksheet) {
yield row
}
}
}
const out = pipeline(
Readable.from(createReader()),
through.obj(function (row, _, cb) {
console.log(row.values)
cb(null, row)
}),
(err) => {
if (err) out.emit('error', err)
}
)You'll see the second column always comes back as a number, even though it should be an ISO string. This file is parsed perfectly fine and gives the correct results when not using streaming mode.
Attached the excel file, you can see the second column is properly date formatted.
Possible solution
I debugged into the library, it seems like the issue is that this is always returning null and not finding the style, which means that later on when it checks the number format to see if it is a date it returns false and just treats it as a number. In the case of this excel sheet, c.s is 2 - so it could be that s is not being parsed right, because it looks like 2 in defaultnumformats.js = general number. I've tried changing to every other date format in excel and re-saving the file and it still comes back as 2 every time.