XLSX.stream.to_json doesn't ends when a blank row is the last row in Excel sheet. #1779
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#1779
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?
sheetjs/bits/97_node.js
Hi @SheetJSDev !
This piece of code has the
R > r.e.r
checking outside of the loop but when a blank row is inserted at the end of a given sheet then theif((row.isempty === false) || (header === 1 ? o.blankrows !== false : !!o.blankrows))
condition inside of the while loop isn't executed and the stream does not end.Ill be submitting a pull request for the same for a fix for this issue that I have found.
Please verify and merge the changes as soon as possible as I am using this library in production in my system.
I'm seeing the same issue, for now I'm having to specify the range to skip processing the blank lines at the end.
@highflying can you please elaborate more when you say
"specify the range to skip processing the blank lines"
I know the range of the sheet that has data in it, so I am specifying it manually, e.g.
When doing this the
end
event gets emitted, without it noend
event happens.Oh makes sense thanks a lot.
Please do make this change live soon I use this in production.
Thanks again for your response.
Ok. If i have many files with variable number of rows and I want to stream it as those are big files.
How do I end the stream then?
@ev45ive
Every worksheet object has "!range" property which gives the range for each worksheet which can be passed in to the
XLSX.stream.to_json
function and you can do it dynamically.@highflying this is interesting. When I use sheet['!ref'] ( which is "A1:O252" ) stream doesn't end.
but when I make it LESS THAN that (by one or more) then it works fine. gets all results and ends stream
Seems like a bug to me, unless I missed something
What version of node are you testing against and can you share the file?
@SheetJSDev
node -v
v12.16.2
"xlsx": "^0.16.0"
Here is file (removed private data, left jsut amounts and dates)
zakup — kopia.xlsx
Now i see there are totals in row 252. But it should still produce messed up record and then end or error instead of silently failing, right?
updated to 0.16.1 . The same issue
stream never ends or errors after last row (totals - see file included above)
I'm having the same issue. I noticed that setting
blankrows: true
will emit the end event. Here my reproducible problem:Can someone check if the following patch fixes the problem (and if so, please feel free to send a PR):
https://github.com/SheetJS/sheetjs/blob/master/bits/97_node.js#L111-L112
The most obvious guess is that in object mode, Readable streams are always expected to push a value. The
null
, which would trigger the end of stream, would not be pushed by the function if the last row is empty AND blank rows are skipped.@rohandhamapurkar this is slightly different from your proposal in that this approach will always push null if there is no more data.