npoi-examples icon indicating copy to clipboard operation
npoi-examples copied to clipboard

How to Remove Row without issues?

Open Kriof opened this issue 2 years ago • 1 comments

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

Kriof avatar Jun 08 '22 13:06 Kriof

Can you upload an example Excel file that will cause Index out of range?

tonyqus avatar Aug 04 '22 21:08 tonyqus