Cannot remove the last row with .spliceRows()
See original GitHub issueHi,
Consider following code:
let Excel = require('exceljs');
let wb = new Excel.Workbook();
let ws = wb.addWorksheet('sheet1');
ws.addRow(['1.1', '1.2', '1.3']);
ws.addRow(['2.1', '2.2', '2.3']);
ws.addRow(['3.1', '3.2', '3.3']);
console.log('rows total: ', ws.rowCount);
for (let i = 1; i <= 3; i++) {
console.log(i, ':', ws.getRow(i).values);
}
ws.spliceRows(3, 1);
console.log('rows total: ', ws.rowCount);
for (let i = 1; i <= 3; i++) {
console.log(i, ':', ws.getRow(i).values);
}
Output before splice:
rows total: 3
1 ':' [ , '1.1', '1.2', '1.3' ]
2 ':' [ , '2.1', '2.2', '2.3' ]
3 ':' [ , '3.1', '3.2', '3.3' ]
Output after splice:
rows total: 3
1 ':' [ , '1.1', '1.2', '1.3' ]
2 ':' [ , '2.1', '2.2', '2.3' ]
3 ':' [ , '3.1', '3.2', '3.3' ]
The expectation is that after splice it will be:
rows total: 2
1 ':' [ , '1.1', '1.2', '1.3' ]
2 ':' [ , '2.1', '2.2', '2.3' ]
3 ':' []
Analogy with arrays:
let a = [1,2,3];
a.splice(2,1);
console.log(a); // => [1,2]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Cant delete last row of data table using vba
Hi. I'm using VBA code in EXCEL developer to delete an entry in a table using the following: SheetName.Range("FirstDataCell").
Read more >Core API reference - JavaScript Data Grid - Handsontable
Removes rows, starting from the last row. 'insert_col_start', Inserts columns before the index column. Inserts columns before the first column.
Read more >exceljs - npm
Once a worksheet is added to a workbook, it cannot be removed. Once a row is committed, it is no longer accessible since...
Read more >exceljs - npm.io
Use the worksheet id to remove the sheet from workbook. ... Equal to the row number of the last row that has values....
Read more >How to delete the last row of data of a pandas dataframe
df.drop(df.tail(n).index,inplace=True) # drop last n rows ... () method and it work but not as kool and readable as using [n:-n], hope that...
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
Using version 4.2.1, still not fixed. My work around was to add a blank row to the bottom of the worksheet before trying to delete.
@GW-GhostWolf Adding just one row may be not enough if number of rows deleted is more than one. Let’s bump it up so the PR is merged.