Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sohail-aspose/ddb6500c965458e0d8e782163151427a to your computer and use it in GitHub Desktop.
Save sohail-aspose/ddb6500c965458e0d8e782163151427a to your computer and use it in GitHub Desktop.
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