Loading a large XLSX file in the form of pages takes up a lot of memory space

When I try to load the pages of an XLSX file with many lines (approx. 13,800), memory amounting to 25 GB is used. The process takes several minutes. Why is this amount of memory needed? Can this happen, when the file seems to have an infinite amount of lines?

I can send you the file for further investigation.

Hi Sarah,

By “lines” are you referring to Excel rows?
The 13-14K rows are really not much and shouldn’t require that much memory.
Yes, please send us your XLSX file so that we can reproduce the issue and investigate it.

Regards,
Mario

Hi Mario,

yes I mean the rows in Excel. :slight_smile:
I sent you the file.

Best regards,
Sarah

Hi Sarah,

I’m afraid I was unable to reproduce your issue, how exactly did you measure that 25 GB?
Here is what I tried:

var workbook1 = ExcelFile.Load("AmagnoService2.xlsx");
Debugger.Break();
var workbook2 = ExcelFile.Load("AmagnoService2.xlsx");
Debugger.Break();
var workbook3 = ExcelFile.Load("AmagnoService2.xlsx");
Debugger.Break();

And on each breakpoint, I took a snapshot of the memory from the Diagnostics Tool.
Here is the result:

In short, I loaded three times your XLSX file into ExcelFile objects, and each object consumed 10MB.

Just in case, please try again with the current latest bugfix version.
I hope that helps.

Regards,
Mario

Are you perhaps saving the ExcelFile to PDF, XPS, or image format?
Note that this will take much more time and memory because the whole content needs to be paginated and rendered.

So yes, I’m afraid that in that case, you will get an increased memory consumption. I presume you meant 2.5 GB which is possible to get.
Anyway, the problem is that the result of rendering this content is almost 4000 pages.

You should consider formatting a bit your sheets in order to reduce the number of pages (for example, increase the page size, use landscape orientation, etc.). Also, you should consider wrapping those extra-long texts in column “E” into multiple lines because they end up occupying far away columns and thus resulting in more cells being allocated when rendering.

Regards,
Mario

Hi Mario,

thank you for the investigation and the hints, as i really try to generate images.

But even before generating images the program needs a lot of memory, the operation that I meant with “load the pages” is:

var file = ExcelFile.Load(filepath);
var pages = file.GetPaginator().Pages;

Within those steps, can I configure somehow to load only a specific number of pages?

Best regards,
Sarah

Hi,

The GetPaginator uses the same rendering engine.
So basically, this call is similar to saving the ExcelFile to PDF, XPS, or image format.

Anyway, I’m afraid there is no way to specify the number of pages.
But there is a way to specify the print area, please check this example:
https://www.gemboxsoftware.com/spreadsheet/examples/excel-print-title-area/104

I hope this helps.

Regards,
Mario

Hi Mario,

thanks, I will look into it with setting the print area.

Best regards,
Sarah