// Create an xlsx file stream FileStream outputStream = new FileStream("OptionsToOptimizeFileSize.xlsx", FileMode.Create); //create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); Stream fileStream = this.GetResourceStream("xlsx\\File needs to be optimized.xlsx"); workbook.Open(fileStream); XlsxSaveOptions options = new XlsxSaveOptions { ExcludeEmptyRegionCells = true, ExcludeUnusedStyles = true, ExcludeUnusedNames = true }; workbook.Save(outputStream, options);
' Create an xlsx file stream Dim outputStream = File.Create("OptionsToOptimizeFileSize.xlsx") ' Create a new Workbook Dim workbook As New Workbook Dim fileStream As Stream = GetResourceStream("xlsx\File needs to be optimized.xlsx") workbook.Open(fileStream) Dim options As New XlsxSaveOptions With { .ExcludeEmptyRegionCells = True, .ExcludeUnusedStyles = True, .ExcludeUnusedNames = True } workbook.Save(outputStream, options) ' close the xlsx stream outputStream.Close()