Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Created Unassigned: ClosedXML IXLRow.Delete() very slow [9317]

$
0
0
Hi there,

I love this product and am trying to use it more and more in my day to day

I have an excel file which has loads of empty rows at the end which I need to delete

When i use the IXLRows.Delete or the IXLRow.Delete (when looping through the rows) i have a major performance issue when it attempts the Delete

The code used here is

var lastRow = ws.LastRowUsed().RowBelow();
var lastUnUsedRow = ws.LastRow();

//ws.Range(lastRow.RangeAddress.FirstAddress.ToString(), lastUnUsedRow.RangeAddress.LastAddress.ToString()).Delete(XLShiftDeletedCells.ShiftCellsUp);

IXLRows rows = ws.Rows();

foreach (IXLRow row in rows)
{
if (row.IsEmpty(true))
{
row.Delete();

var lastUnUsedCell = ws.RowsUsed().Count();
}
}

The above code, which is deleting only one row, has been running for a good 7 minutes now and not completed yet.

Is there a better way to do this?

I'm using version version 0.69.1.0 of the DLL

Thank you

Viewing all articles
Browse latest Browse all 1877

Trending Articles