Deleting blank rows not working


I need to delete blank rows in a worksheet (see that attached FileWithBlankCells and the ExpectedOutput files). Essentially, I would like to delete the rows that have no data.

I have so far tried Cells.DeleteBlankRows() and Cells.DeleteRange() and none of these are giving the expected result. Please can you provide a code that produces the expected output.


Thanks

Hi,


Thanks for your template file and expected file.

Please see the following sample code, it would work fine as per your expected results. I have used your template file in the sample code.
e.g
Sample code:

Workbook workbook = new Workbook(“e:\test2\FilewithBlankCells.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
//Get the minimum firt data row.
int mrow = worksheet.Cells.MinDataRow;
worksheet.Cells.DeleteBlankRows();
worksheet.Cells.DeleteBlankColumns();

//Since you want to retain initial blank rows, so you may insert n number of blank rows.
worksheet.Cells.InsertRows(0, mrow);


workbook.Save(“e:\test2\out1.xlsx”);

Hope, this helps a bit.

Thank you.