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.
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.
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:
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.