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 skips empty rows

See original GitHub issue

When calling xlsx.utils.sheet_to_json(sheet, {header: 1}) I would expect to receive an array of arrays including empty rows. However the function explicitly skips out empty rows which makes it impossible to select a particular row in the results. It would be good to make this behaviour configurable.

As a workaround, I have used sheet_to_csv, which doesn’t skip rows, followed by csv-parse.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:42 (6 by maintainers)

github_iconTop GitHub Comments

23reactions
clarkmucommented, Aug 3, 2018

It was also not working for me until I added the ‘defval’ param: var roa = XLS.utils.sheet_to_row_object_array(workbook.Sheets[sheetName], {defval: ‘’})

17reactions
ryankallcommented, May 22, 2018

@EDUARDOMBRAGA @SheetJSDev

I am using angular 6 and it will work on angular 5… package.json "xlsx": "^0.12.13" in File import * as XLSX from 'xlsx';

This will work on xlsx, Only one I used it on. XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: 1, defval: null});

defval does the magic here, ‘null’ is what I want in place if I wanted empty string in place of empty cell XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header: 1, defval: ''});

defval can be any value you set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sheet_to_json does not skip blank rows · Issue #1078 - GitHub
In this call, sheet_to_json will skip blank rows (since we did not specify header: 1 ). The {a: ""} object is generated since...
Read more >
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
blankrows must be set to false to skip blank lines. Fields containing the record or field separator will automatically be wrapped in double...
Read more >
A brand new website interface for an even better experience!
sheet_to_json skips empty rows.
Read more >
Ho to skip blank rows while reading data from the excel sheet
Hi, We want to skip the blank rows while reading data from the excel sheet. Is there any method that we can use...
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