How can I prepare large Excel files before zipping to keep everything intact?

I have been working with large Excel files that contain multiple sheets, formulas, charts, and images. These files are often very heavy and when I try to compress them I worry about losing formatting or breaking formulas. I have tried cleaning up hidden sheets and removing unused ranges but I am not sure if this is enough

I was inspired by the idea of using a file to zip process. File to zip simply means taking one or more files and compressing them into a single archive so they are easier to store or share. I recently used a free file zipping website and it made the process simple and fast without installing anything. It made me realize how helpful online compression can be for managing large files

My main question is what is the best way to prepare large Excel files before using a zip tool to make the final archive smaller while keeping all formulas charts and formatting intact. I would like to know if there are steps or techniques others use to make sure the compressed file works perfectly after extraction and stays organized especially when handling multiple large files.

@immiran

Summary
Large Excel workbooks can be reduced in size before they are placed in a ZIP archive. By cleaning up unused rows/columns, removing unused styles and names, and recompressing embedded images, you keep all formulas, charts, and formatting while producing a smaller .xlsx file that the ZIP process can compress more efficiently.

Why it happens

  • Unused cells / styles / names – Excel stores every cell that has ever been touched and retains styles and defined names even if they are no longer used. This extra XML inflates the workbook size.
  • Embedded images – Pictures are kept in the original format (often BMP or high‑resolution PNG) and are not re‑compressed when the workbook is zipped.
  • Default ZIP settings – The generic ZIP algorithm does not apply Excel‑specific optimisations such as removing empty parts or using the highest compression level.

What to do next

  1. Load the workbook
// Load the original workbook
var workbook = new Aspose.Cells.Workbook(@"C:\Input\LargeFile.xlsx");
  1. Delete empty rows and columns (outside the used range)
foreach (var ws in workbook.Worksheets)
{
ws.Cells.DeleteEmptyRowsAndColumns();
}
  1. Remove unused objects
// Styles, defined names and custom XML parts that are not referenced
workbook.RemoveUnusedStyles();
workbook.RemoveUnusedNames();
workbook.RemoveUnusedCustomXmlParts(); // available in recent versions
  1. Re‑compress embedded pictures
foreach (var ws in workbook.Worksheets)
{
foreach (var pic in ws.Pictures)
{
// Convert to JPEG with 80 % quality (or keep PNG for lossless)
pic.ImageFormat = Aspose.Cells.Drawing.ImageFormat.Jpeg;
pic.ImageQuality = 80;
}
}
  1. Save with maximum ZIP compression
var saveOptions = new Aspose.Cells.OoxmlSaveOptions
{
CompressionLevel = 9, // 0 = none, 9 = maximum
EnableZip64 = true, // supports files > 4 GB
// The following options are default for XLSX, but can be set explicitly
PreserveFormulas = true,
PreserveCharts = true,
PreserveFormatting = true
};

string cleanedPath = @"C:\Temp\LargeFile_Cleaned.xlsx";
workbook.Save(cleanedPath, saveOptions);
  1. Create the ZIP archive (standard .NET compression is sufficient)
using (var zip = new System.IO.Compression.ZipArchive(
System.IO.File.OpenWrite(@"C:\Output\LargeFile.zip"),
System.IO.Compression.ZipArchiveMode.Create))
{
zip.CreateEntryFromFile(
cleanedPath,
"LargeFile.xlsx",
System.IO.Compression.CompressionLevel.Optimal);
}
  1. Validate the result
  • Extract the ZIP file.
  • Open LargeFile.xlsx in Excel and verify that all formulas, charts, images, and formatting appear as expected.
  • (Optional) Call workbook.CalculateFormula(); before saving if you want to ensure volatile formulas are up‑to‑date.

Additional tips

Setting / technique Effect When to use
workbook.Settings.EnableMemoryOptimization = true; Reduces memory consumption while processing very large files. Workbooks larger than ~200 MB.
workbook.DefaultFont = "Arial"; Provides a fallback font and avoids embedding unnecessary font data. When custom fonts are not required.
OoxmlSaveOptions.CompressionLevel = 9 + EnableZip64 = true Maximises ZIP compression and allows archives > 4 GB. When the final ZIP must stay under a size limit or be emailed.

Following these steps will keep all Excel features (formulas, charts, images, conditional formatting, etc.) intact while delivering a considerably smaller, zip‑ready file. The workflow can be scripted and integrated into any build or upload pipeline to ensure every large workbook is optimised before archiving or transfer.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

@immiran,

I think you may consider the following suggestions when preparing your Excel files to help optimize or reduce their file size. You may do it manually or use Aspose.Cells to implement the following aspects programmatically in apps:

Optimize File Format
Save your Excel file in binary format (.xlsb) if possible as it can reduce file size by 30% or more while maintaining all functionalities intact.

Check for Hidden Data
Ensure that there are no empty rows, hidden sheets, or unnecessary data in your file, as these can bloat file size significantly.

Manage Embedded Objects & Formatting
Reducing excessive pictures, external links, and complex formats can lower the file size and make compression more effective without losing essential elements.
etc.

Moreover, we have Aspose.ZIP API that provides means for file compression and archiving programmatically. The library enables developers to compress, archive, and extract files within your desired environment, ensuring efficient integration and performance.