npoi-examples
npoi-examples copied to clipboard
How to Remove Row without issues?
Hi, I;m trying to RemoveRow using
sheet.RemoveRow(row); // this only deletes all the cell values
int rowIndex = row.RowNum;
int lastRowNum = sheet.LastRowNum;
if (rowIndex >= 0 && rowIndex < lastRowNum)
{
sheet.ShiftRows(rowIndex + 1, lastRowNum, -1);
}
Above solution causes some issues:
- Index out of range on some cells with values
- Excel file after opening have pre-selected last row and column(Despite it's empty)
How can i remove rows without complications
Can you upload an example Excel file that will cause Index out of range?