Wrong behavior when reading a specific XLSX file #3023

Closed
opened 2023-10-30 18:48:42 +00:00 by noghartt · 3 comments

I'm trying to parse a specific XLSX file, but when use the readFile or read functions, these cells seems to be empty. Even with the spreadsheet editors displaying that they exists. If I save again the same spreadsheet, it works as expected.

Attached a xlsx file that has this wrong behavior.

The code that we're using to read the file is:

This behavior happens in both versions: 0.18.5 and 0.20.0.

import * as XLSX from 'xlsx';

const wb = XLSX.readFile('test.xlsx', {
  cellDates: true,
});

console.log(wb); // seems to have empty cells
I'm trying to parse a specific XLSX file, but when use the `readFile` or `read` functions, these cells seems to be empty. Even with the spreadsheet editors displaying that they exists. If I save again the same spreadsheet, it works as expected. Attached a `xlsx` file that has this wrong behavior. The code that we're using to read the file is: This behavior happens in both versions: `0.18.5` and `0.20.0`. ```js import * as XLSX from 'xlsx'; const wb = XLSX.readFile('test.xlsx', { cellDates: true, }); console.log(wb); // seems to have empty cells ```
9.3 KiB
Owner

https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data

You can pass the option nodim: true to the read or readFile functions, or you can use the workaround shown in the docs page.

https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data You can pass the option `nodim: true` to the `read` or `readFile` functions, or you can use the workaround shown in the docs page.
Author

https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data

You can pass the option nodim: true to the read or readFile functions, or you can use the workaround shown in the docs page.

I already tried both solutions as I see in issues aroung GitHub and here. None of them works.

image

The !ref property already comes with the right range of how much rows and columns has on my document.

> https://docs.sheetjs.com/docs/miscellany/errors#worksheet-only-includes-one-row-of-data > > You can pass the option `nodim: true` to the `read` or `readFile` functions, or you can use the workaround shown in the docs page. I already tried both solutions as I see in issues aroung GitHub and here. None of them works. ![image](/attachments/b15e4473-82b3-4e4c-9aca-13be30539776) The `!ref` property already comes with the right range of how much rows and columns has on my document.
6.0 KiB
noghartt reopened this issue 2023-10-30 21:20:55 +00:00
Owner

NodeJS test against the attached file:

  1. Save the following to test.js:
var XLSX = require("xlsx");
var wb = XLSX.readFile("1a355e34-c720-420d-870a-2bc2a29724cc", {nodim: true});
console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]));
  1. Download the test file:
curl -LO https://git.sheetjs.com/attachments/1a355e34-c720-420d-870a-2bc2a29724cc
  1. Install the SheetJS CE library:
npm i --save https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz
  1. Run the script:
node test.js
Result (click to show)
[
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 7756827724 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 64981277542 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 13158753499 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 4070286411 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 },
  { 'Chave Pix do Recebedor': 22513107896 }
]
NodeJS test against the attached file: 1) Save the following to `test.js`: ```js var XLSX = require("xlsx"); var wb = XLSX.readFile("1a355e34-c720-420d-870a-2bc2a29724cc", {nodim: true}); console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]])); ``` 2) Download the test file: ```bash curl -LO https://git.sheetjs.com/attachments/1a355e34-c720-420d-870a-2bc2a29724cc ``` 3) Install the SheetJS CE library: ```bash npm i --save https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz ``` 4) Run the script: ```bash node test.js ``` <details><summary><b>Result</b> (click to show)</summary> ```js [ { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 7756827724 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 64981277542 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 13158753499 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 4070286411 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 }, { 'Chave Pix do Recebedor': 22513107896 } ] ``` </details>
Sign in to join this conversation.
No Milestone
No Assignees
2 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#3023
No description provided.