Worksheet.spliceRows has inconsistent results based on splice count
See original GitHub issueI am using exceljs 1.6.2.
I am seeing completely contradicting results based on how large of a number I pass in for the count
argument for spliceRows
.
First case, in which it seems to work as expected:
const spliceStart = 3; // Start removing at row three.
const countBefore = this._worksheet.rowCount; // 233
this._worksheet.spliceRows(spliceStart, 2); // Remove 2 rows.
const countAfter = this._worksheet.rowCount; // 231
const diff = countBefore - countAfter; // 2
Second case, in which count
seems to be how many rows it keeps rather than how many it removes:
const spliceStart = 3; // Start removing at row three.
const countBefore = this._worksheet.rowCount; // 233
this._worksheet.spliceRows(spliceStart, 200); // Remove 200 rows.
const countAfter = this._worksheet.rowCount; // 202
const diff = countBefore - countAfter; // 31
What I really need is to remove all rows past row 2, but that actually results in NO rows being removed:
const lastRowToKeep = 2; // Start removing rows after row two.
const spliceStart = lastRowToKeep + 1; // Start removing at row three.
const countBefore = this._worksheet.rowCount; // 233
const spliceCount = countBefore - lastRowToKeep; // 231
this._worksheet.spliceRows(spliceStart, spliceCount); // Remove 231 rows.
const countAfter = this._worksheet.rowCount; // 233
const diff = countBefore - countAfter; // 0
I have no idea what to make of these results.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Worksheet.spliceRows has inconsistent results based on ...
I am using exceljs 1.6.2. I am seeing completely contradicting results based on how large of a number I pass in for the...
Read more >exceljs - npm
A count of the number of columns that have values. Page Setup ⬆. All properties that can affect the printing of a sheet...
Read more >Ways to count values in a worksheet - Microsoft Support
Count cells in a range based on multiple conditions by using the COUNTIFS function. The COUNTIFS function is similar to the COUNTIF function...
Read more >Add rows before the column header using excel.js module + ...
I have tried a lot of things to get the sheet.columns functionality to leave the first row ... spliceRows(1, 0, titleValues1,titleValues2);.
Read more >V~anEddy - William J. Hughes Technical Center - FAA
current lap splice inspections at transport aircraft maintenance facilities, reliability ... The result of AANC's efforts is a three volume document, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Reviewing the code of spliceRows() - basically if number of rows remaining after the deleted part is less than count, nothing happens.
There needs to be another loop in spliceRows() that would delete all the rows that should be deleted but are not handled by the loop that copies existing rows over to where deleted rows are.
As it stands now, spliceRows() is useless to delete rows at the end of the worksheet.
loop is to slow,when I splice 20000 rows,it cost 40min