XLSX file size bloats after it's opened and saved for the first time using C#.NET

Hi all,


I have an odd thing happening and was wondering if anyone could help. Here’s the scoop:

I have some code that uses Aspose.Cells to generate a .xlsx file, which ends up being around 2MB in size. After it’s opened by Excel and saved for the first time, it automatically bloats up to around 7MB. I used 7zip and a file comparison tool to compare the before and after of one worksheet, and found that the difference is in the sheet data section, specifically in all of the nodes:

2MB version:
561

7MB version:

<c r=“BG10” s=“3” t=“s”>
561

This particular workbook has around 50ish columns and anywhere from 5k to 20k rows, so it’s easy to see how this additional ‘r’ attribute is at least contributing to the bloat.

It’s a long shot, but has anyone else in the community experienced this? Is there something I can do when generating the file with Aspose.Cells to keep this from happening?

Thanks in advance!
Jim

Hi Jim,

In
order to increase the performance and reduce the file size, by default,
Aspose.Cells does not exp cellName to xlsx if not necessary.
But Ms Excel will exp cellName to xlsx, so the file will bloat if open and saved by Ms Excel. If you need to export cellName information to xlsx, you may try the following code lines.

OoxmlSaveOptions option = new OoxmlSaveOptions(Aspose.Cells.SaveFormat.Xlsx);
option.ExportCellName = true; // default value is false
report.Save(“myfile.xlsx”, option);

You will see the size of file saved by Aspose.Cells is almost equal to the one saved by MS Excel.

In your current scenario, <c r=“BG10” s=“3” t=“s”> r=“BG10” is the cell name.

Sounds like there’s nothing I can do to keep Excel from automatically adding the cell name attribute to each cell node. Unfortunate, but that’s how it goes.


Thanks for the reply!

Jim