sheet_to_json does not skip blank rows #1078
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#1078
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have the following configuration which works fine in general:
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 ?
Can you share the file?
@SheetJSDev There has to be something with the file itself... If I copy contents to a new file, it would not behave like that
sample.xlsx
This is a funny logical error: when a default value is specified, the row is marked as nonempty. That doesn't really make sense in retrospect. The fix is simple:
@SheetJSDev Yes, that does it! Thanks a million, you saved my life 💯
This will be in the next release, we're aiming for tomorrow and will close the issue then.
Fantastic, keep up the great work!
I'm currently using the version "0.14.0". I'm facing the same issue.
still parses all the blank rows. Does this issue still persists ?
@SheetJSDev I am getting same issue as @sainiankit.
using version 0.14.0 setting blankRows and defVal doesn't work:
var sheetThreeArray = X.utils.sheet_to_row_object_array(workbook.Sheets[sheetThree], {blankRows: false, defval: ''});
Hi, on version 0.14.2, I modified the plugin on the function adding on line 20545:
and modifying on line 20562
if (v != null && v.toString().trim().length > 0) isempty = false;
Complete function code:
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
Thanks for @mehars-jalin , it worked for me.
There is some issue with the sheet I was using. If you are running into an issue with { blankrows: false } then make sure to clear contents of all cells below.
@SheetJSDev
Please help
//Note: Empty cell are there, shown when uploaded the excel but i need one favor
//how can i higlight the empty cell with border-color and an error message to the user for understanding the empty cell.
let workBook = null;
let jsonData = null;
this.fileData = this.files[0]
const reader = new FileReader();
const file = this.files[0];
reader.onload = (event) => {
const data = reader.result;
workBook = XLSX.read(data, { type: 'binary' });
jsonData = workBook.SheetNames.reduce((initial, name) => {
const sheet = workBook.Sheets[name];
//Note: Empty cell are there, shown when uploaded the excel but i need one favor
//how can i higlight the empty cell with border-color and an error message to the user for understanding the empty cell.
});
this.router.navigate(['/demand']);
this.heroService.tableDemostructure.next( this.fileData)
return initial;
}, {}
);
var dataString = JSON.stringify(jsonData);
localStorage.setItem("testJSON", dataString);
let obj = JSON.parse(text);
//document.getElementById("demo").innerHTML = obj;
//document.getElementById('output').innerHTML = dataString.slice(0, 300).concat("...");
//this.setDownload(dataString);
}
You must be add the
blankrows: true
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:
I'm on version 0.17.5. Please help.