-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[BUG] spliceRows doesn't work on the last row #2125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey! I've been having this issue among others recently, I have found/developed a workaround for this. You can use this function to delete rows from a worksheet: function deleteRows(worksheet, start, count, rowCount) {
for (let i = 0; i < count; i++) {
if (rowCount && start + i === rowCount) {
// Workaround fix for deleting the last row.
worksheet.spliceRows(start, 1, []);
}
else {
worksheet.spliceRows(start, 1);
}
}
} With this, Hope this helps. |
Still exists at |
I have the same problem. |
This code has allowed me to work around the problem. test('rowCount will not be reduced', () => {
const wb = new ExcelJS.workbook();
const ws = wb.addWorksheet();
ws.addRows([['1st'], ['2nd'], ['3rd']);
deleteRows(ws, 2, 2, ws.rowCount);
expect(ws.rowCount).not.toBe(1);
});
|
🐛 Bug Report
Removing rows in worksheet with spliceRows works except for the last row.
Lib version: 4.3.0
Steps To Reproduce
The expected behaviour:
Last row to be removed
Is there another way to delete/remove (last) row than using spliceRow?
The text was updated successfully, but these errors were encountered: