dateNF option ignored when reading XLS files #1693

Closed
opened 2019-11-27 12:46:45 +00:00 by rldcampbell · 1 comment
rldcampbell commented 2019-11-27 12:46:45 +00:00 (Migrated from github.com)

First of all, many thanks for your extremely useful work on this project!

I seem to be running into a small issue in that when reading .xls files the dateNF options appears to be ignored. So running something like:

const wb = xlsx.readFile("./Path/to/file.xls", { dateNF: "yyyy-mm-dd", cellDates: true })

reads in the file, but the w property for a date cell has value e.g. "7/1/19" instead of "2019-07-01" as I would expect. This does not seem to be a problem for .xlsx files.

I note that there is a line that uses the SSF.format() function but does not pass it the dateNF option value:
1a5bba267b/bits/76_xls.js (L84)
Is there a reason for this? Changing this to

else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904, dateNF: opts ? opts.dateNF : undefined});

seems to solve the issue for me, but I do not have a deep understanding of the package.

I will send a basic example file with a snippet to the e-mail address specified in the guidelines.

Thanks again for your time

First of all, many thanks for your extremely useful work on this project! I seem to be running into a small issue in that when reading `.xls` files the `dateNF` options appears to be ignored. So running something like: ```js const wb = xlsx.readFile("./Path/to/file.xls", { dateNF: "yyyy-mm-dd", cellDates: true }) ``` reads in the file, but the `w` property for a date cell has value e.g. `"7/1/19"` instead of `"2019-07-01"` as I would expect. This does not seem to be a problem for `.xlsx` files. I note that there is a line that uses the `SSF.format()` function but does not pass it the `dateNF` option value: https://github.com/SheetJS/sheetjs/blob/1a5bba267b6544b0015e3afd3c37483641ff053b/bits/76_xls.js#L84 Is there a reason for this? Changing this to ```js else p.w = SSF.format(fmtid,p.v, {date1904:!!date1904, dateNF: opts ? opts.dateNF : undefined}); ``` seems to solve the issue for me, but I do not have a deep understanding of the package. I will send a basic example file with a snippet to the e-mail address specified in the guidelines. Thanks again for your time
SheetJSDev commented 2021-09-20 07:11:50 +00:00 (Migrated from github.com)

That change is reasonable and we will add a commit and credit you :)

That change is reasonable and we will add a commit and credit you :)
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1693
No description provided.