I'm using NPOI to clear data of all rows from a given row index all the way to the last row using the following function:
public void DeleteToLastRow(ISheet sheet, int firstRowIndex)
{
int lastRowIndex = sheet.LastRowNum;
for (int rowIndex = lastRowIndex; rowIndex >= firstRowIndex; rowIndex--)
{
var deletedRow = sheet.GetRow(rowIndex);
// All rows are warrantied to be not null
sheet.RemoveRow(deletedRow);
}
}
However, I have around 100 cells in each row, and around 80 cells out of those 100 have some complex formula. Because of that, it takes me about 8 seconds to delete 200 rows. Is there any way to increase performance in this case?
Most cells reference to 3 or 4 other cells at the start of the same row. They also reference to 1 fixed cell at the start of the sheet that I do not delete.
I'm using .Net 4.6.2, NPOI 2.3.0, my file is xlsx so I'm using XSSF.