I use EPPlus to delete only one row with index 10 using this code:
using (var p = new ExcelPackage(fi))
{
var ws = p.Workbook.Worksheets[1];
ws.DeleteRow(10, 1);
}
When I save output file I see that row is exist in file:
p.SaveAs(new FileInfo("c:\\output.xlsx"));
Why row is not deleted?
My full code is:
using(var p = new ExcelPackage(fi)) {
var ws = p.Workbook.Worksheets[1];
var start = ws.Dimension.Start;
var end = ws.Dimension.End;
for (int row = start.Row + 1; row <= end.Row; row++) {
for (int col = start.Column; col <= end.Column; col++) {
var value = ws.Cells[row, 5].Value ? ? string.Empty;
if (value == null || value == String.Empty || value == "") {
ws.DeleteRow(row, 1);
}
}
}
p.SaveAs(new FileInfo("c:\\Projects\\excel\\output.xlsx"));
}
I try delete all rows where values in column with index 5 is empty