We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Memory issues converting Office Docs to Excep


Our order ID was: 160818091337

We are using your DLL to for only one purpose: convert Office docs to PDF.

But the version we have has a major bug: Excel files with lots of rows are not converted to PDF efficiently, causing memory issues, Our CPU is spiking and memory timeout issues are happening during conversion.

Can you tell us if you have a fix for this issue?




Thanks for providing us details.

Please try our latest version/fix: Aspose.Cells for .NET v19.3.x (if you are not already using it).
If you still find the issue with v19.3, kindly do provide us sample Excel files (you may zip the file(s) prior attaching here) to reproduce the issue on our end, we will test your scenario/case by converting the file(s) to PDF file format and provide our feedback soon.


Thanks for the template files, screenshots and details.

I have evaluated both your mentioned issues using your template files (“Book1.xlsx” and “Book2.xlsx”). I firstly opened both your files into MS Excel manually and found:

  1. Book1.xlsx file has more than 6000 pages in Sheet1
  2. Book2.xlsx file has more than 1800 pages in Sheet1
    (Note: I take the print preview of the sheets of both workbooks in MS Excel manually)

Now seeing your line of code in your code segment you shared:

pso.OnePagePerSheet = true;

This is the culprit line. How could you render one page per those large sheets with so many pages. I am afraid, this is not possible i.e., render so much data into a single page, so you cannot render the big sheets (of so many pages) into a single page. You may confirm this even you cannot do this in MS Excel either manually. In short, please remove this line of code or comment this line.

The core thing is when Aspose.Cells tries to render (with so many records on the sheet(s)) to one page, it consumes more memory and CPU for sure, but at the end it becomes impossible to accomplish the task (render so many records into one PDF page). Sometimes, at the end, it gives out of memory error too.

For your information, OnePagePerSheet option is valid only when there are few pages like 4-10 or so. If there are more pages as in your case then OnePagePerSheet might throw out of memory exception and would be useless. Because it is impossible to render lots of pages into a single PDF page. So, first check how many pages are there in your worksheet (you may take the print preview of the sheet in MS Excel manually and get the total number of pages) and then decide if you should use OnePagePerSheet option or not.

Aspose.Cells is surely capable of rendering large MS Excel files to PDF file format speedily and efficiently. The output will be same as original file. Many of our clients are using Aspose.Cells to render their big files to image or PDF file format without any issue. The main thing is how you are rendering those big files using Aspose.Cells APIs, so you should adjust your code accordingly.

Hope, this helps a bit.

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46648 - Exception "Shape to image Error!" while converting XLSX to PDF

Regarding that 2MB file issue, it is still creating the PDF around 8-12 MB which is much higher than the conversion does by other tools. Can you share how to prevent that?


Are you referring to Book2.xlsx file? If not, could you share the template file and output PDF, we will check it soon.


We have tried this conversion using Excel 365 which creates PDF file of size 36 MB, however we have also observed the small size PDF created by iLovePDF service. We need to look into it more and have logged the issue in our database for investigation and for a fix (if applicable). Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46649 - Large PDF generated as compared to online tool iLovePDF


While we evaluate your issue in details, could you try to optimize the output PDF for size in code, see the line of code in bold for your reference:
Sample code:

Workbook workBook = new Workbook(“e:\test2\Book2.xlsx”);
foreach (Worksheet sheet in workBook.Worksheets)
sheet.PageSetup.PrintArea = “”;

        Aspose.Cells.PdfSaveOptions pso = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
        //Set the compliance type
        pso.Compliance = Aspose.Cells.Rendering.PdfCompliance.PdfA1b;

pso.OptimizationType = PdfOptimizationType.MinimumSize;

            workBook.Save("e:\\test2\\out1.pdf", pso);

I have tested it and it does minimize the size to certain extent.

Let us know your feedback.


In the fix V19.3.1, the output PDF file size will be about 4MB by setting PdfOptimizationType.MinimumSize:

Workbook workBook = new Workbook("Book2.xlsx");
foreach (Worksheet sheet in workBook.Worksheets)
    sheet.PageSetup.PrintArea = "";
PdfSaveOptions pso = new PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);
//Set the compliance type
pso.Compliance = PdfCompliance.PdfA1b;
pso.OptimizationType = PdfOptimizationType.MinimumSize;

workBook.Save(outFile.pdf, pso);

Please try our latest version/fix: Aspose.Cells for .NET v19.3.1:

Aspose.Cells19.3.1 For .NetStandard20.Zip (4.0 MB)
Aspose.Cells19.3.1 For .Net2_AuthenticodeSigned.Zip (4.8 MB)
Aspose.Cells19.3.1 For .Net4.0.Zip (4.8 MB)

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-46649) have been fixed in Aspose.Cells for .NET v19.4. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi