Free Support Forum - aspose.com
Deleting emty rows
Aspose.Cells Product Family
Alex1305
March 28, 2017, 9:17am
1
Hi,
How to delete all empty (null) rows on all worksheets(except first and second) of a workbook?
Thank you.
amjad.sahi
March 28, 2017, 10:02am
2
Hi,
Thanks for your query.
I think you may try to use Cells.deleteBlankRows() and Cells.deleteBlankColumns to remove the rows/columns which are blank irrespective if those rows/columns are formatted. See the sample code segment for your reference:
e.g
Sample code:
WorksheetCollection worksheets = workbook.getWorksheets();
//Get the third worksheet. Similarly you may easily loop through all the worksheets to remove the blank rows/cols in your favourite worksheets only.
Worksheet sheet = collection.get(2);
sheet.getCells().deleteBlankColumns();
sheet.getCells().deleteBlankRows();
…
Hope, this helps a bit.
Thank you.