Created
December 24, 2020 11:49
-
-
Save sohail-aspose/c87d1de331de3b6aa01eb0705aa81c96 to your computer and use it in GitHub Desktop.
Delete the blank rows and columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 and columns. | |
DeleteOptions options = new DeleteOptions(); | |
options.UpdateReference = true; | |
// Delete the blank rows and columns. | |
sheet.Cells.DeleteBlankRows(options); | |
sheet.Cells.DeleteBlankColumns(options); | |
// Calculate formulas of workbook | |
wb.CalculateFormula(); | |
// 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