3

I'm having an issue where if I try to read a row that was originally a date, it gets converted to a number like : Last_Contact_Date: 45618 from the original 31/05/2024 in the file. Can this somehow be prevented and if not can you recommend a library to convert it to a proper date.

My worksheet is configured as follows:

const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(
    tempFilePath,
    {
        sharedStrings: "cache",
        worksheets: "emit",
    }
);

And here I'm reading the values:

        worksheet.on("row", async row => {
            //Date values are numbers
            const values = row.values.slice(1);
        });
2
  • 2
    voted for reopening, as this question is about ExcelJS, not SheetJS/xlsx Commented May 17 at 11:43
  • 2
    Yeah, en entire different library @traynor. Thanks for your answer though, It helped Commented May 17 at 13:01

1 Answer 1

3

Try adding styles: "cache" to the options:

const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(
    tempFilePath,
    {
        sharedStrings: "cache",
        worksheets: "emit",
        styles: "cache",
    }
);

it seems there's some problem with styles, see: [BUG] date parsing doesn't work in streaming mode #1430

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.