sheet_add_json with origin: -1 leaves gap from bottom of worksheet #1364
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#1364
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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'm seeing strange behavior with the following code:
I expected
p3
...p8
to be placed on rows 3 ... 8, but they ended up on rows 6 ... 11 (in LibreCalc at least).I'm on 0.14.1. What might be going on?
Did some more digging. Looks like if the JSON array has N >= 4 elements, the library inserts N - 3 empty rows, if the existing worksheet has 2 rows.
The logical error is in https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L193-L199 : when
origin: -1
is specified and the number of rows inserted exceeds the number of rows in the file, it is added twice.It would probably be simpler to proactively wraparound by checking if
_R < 0
in https://github.com/SheetJS/js-xlsx/blob/master/bits/90_utils.js#L186 and just adding the number of rows in the worksheet. This would also handle cases like -2 for the penultimate row.Thanks for confirming and looking forward to the fix!
Made a pull request that solves the issue #1463 @dandv
Yay! First time I'm about to award a bounty, after years of using BountySource :)
@SheetJSDev, can you please test and merge if everything checks out?
Hey @SheetJSDev, ping :)
Here's a 2020 ping!
workaround with the advantage of writing new columns header if your object has new properties
Greetings from 2021 ❗
This was fixed in a slightly different way (by updating the anchor row) in v0.16.0:
That said, the bounty should be awarded to @dongido001 in recognition of the effort.