question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sheet_to_json does not skip blank rows

See original GitHub issue

I have the following configuration which works fine in general:

    let lte = await XLSX.utils.sheet_to_json(workbook.Sheets['Sheet1'], {
      blankRows: false,
      defval: '',
    });

However, I have an excel with 14K rows. I deleted the values in all but one row for test (there is styling in empty rows such as borders and colors but no values). When parsing, sheetjs still attempts to parse all of 14K rows for some reason.

Any ideas what’s causing it ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

28reactions
mehars-jalincommented, May 11, 2019

I faced the same issue, and after spending 1 hour, I decided to take a look at the function and discovered that the keyname is NOT camelcase, as documented. So use, blankrows NOT blankRows

3reactions
crazyjatcommented, Jun 13, 2022

I am experiencing this issue when trying to read an xlsx file from user upload that contains empty formulas. For example, I have cells that are empty that contain a formula such as =IF($A12 <> "", VLOOKUP(ObjectivesUI!G12,ENUM!E:F,2,0),"") The imported cells look like { t: "s", v: "" } and nothing I do will filter them out.

This is what my import function looks like:

const getXlsxData = (file: File): Promise<WorkBook> => {
  return new Promise(resolve => {
    let reader = new FileReader();
    reader.onload = (e) => {
      if (e.target?.result) {
        let workbook = read(e.target.result, {
          cellDates: true,
          cellFormula: false,
          cellNF: false,
          cellHTML: false,
          cellText: false,
        });
        resolve(workbook);
      }
    };
    reader.readAsArrayBuffer(file);
  });
}

I’m on version 0.17.5. Please help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SheetJS shows blank rows - Stack Overflow
In order to remove the rows without any data you can use the option blankRows: false , like this: const data = XLSX.utils.sheet_to_json(ws, ......
Read more >
Utility Functions - SheetJS Community Edition
All fields from each row will be written! header hints at a particular order but is not exclusive. To remove fields from the...
Read more >
docbits/82_util.md | sheetjs@v0.18.3 - Deno
When header is 1 , the default is to generate blank rows. blankrows must be set to false to skip blank rows. When...
Read more >
xlsx - npm
The library does not impose a separate lifecycle. ... The sheet_to_json utility function walks a workbook in row-major order, generating an ...
Read more >
How to Remove Blank Rows in Excel (Quick & Easy)
Having a dataset with blank or empty rows can lead to confusion or give the impression that data is missing when it might...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found