Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update References While Deleting Blank Rows
// Open an existing excel file.
Workbook wb = new Workbook("SampleInput.xlsx");
// Get the worksheets collection in the spreadsheet.
WorksheetCollection sheets = wb.Worksheets;
// Get first Worksheet from WorksheetCollection by index.
Worksheet sheet = sheets[0];
// This option will ensure the references (in formulas, charts)
// are updated while deleting blank rows.
DeleteOptions options = new DeleteOptions();
options.UpdateReference = true;
// Delete the Blank Rows from the worksheet.
sheet.Cells.DeleteBlankRows(options);
// Save the excel file.
wb.Save("SampleOutput.xlsx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment