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

Free Support Forum - aspose.com

Pdf Generation => OutOfMemoryException

Hello,
i’m currently testing Aspose Cells.Net for my client. He needs to create Xlsx files and eventually convert it to pdf. Aspose Cells should do that. Nonetheless, when i build a large Excel table, i can get either an OutOfMemoryException or a broken pdf file. Xlsx generation just work fine with the same amount of data. I’ve found some similar issues on version 5.X. Is it the same issue? How can i manage to make it work?

Here is the code i use for test purposes:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aspose.Cells;

namespace TestAspose
{
class Program
{
static void Main(string[] args)
{

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(Aspose.Cells.FileFormatType.Pdf);
wb.Worksheets.Clear();
Aspose.Cells.Worksheet sheet=wb.Worksheets.Add(“MyWorksheet”);
if (!wb.IsColorInPalette(System.Drawing.Color.LightCoral))
wb.ChangePalette(System.Drawing.Color.LightCoral, 49);

if (!wb.IsColorInPalette(System.Drawing.Color.LightGray))
wb.ChangePalette(System.Drawing.Color.LightGray, 50);


Style style = wb.Styles[wb.Styles.Add()];
Style alternateStyle = wb.Styles[wb.Styles.Add()];


style.Font.Color = System.Drawing.Color.Black;
style.ForegroundColor = System.Drawing.Color.LightCoral;
style.Pattern = BackgroundType.Solid;
style.IsLocked = true;

alternateStyle.Font.Color = System.Drawing.Color.Black;
alternateStyle.ForegroundColor = System.Drawing.Color.LightGray;
alternateStyle.Pattern = BackgroundType.Solid;

for(int i=0;i<90000;i++)
{
for(int a=0;a<25;a++)
{
sheet.Cells[i, a].PutValue(string.Format(“Ligne {0} Colonne {1}”, i.ToString(), a.ToString()));

if (i % 2 == 0)
{
sheet.Cells[i, a].SetStyle(style, true);


}
else
{
sheet.Cells[i, a].SetStyle(alternateStyle,true);
}

}
}
sheet.AutoFitColumns();
sheet.AutoFitRows();

wb.Save(@“c:\test.pdf”);

wb = null;

}
}
}


Hi,


Well, since you are populating lots of cells (90k rows * 25 columns) in a huge worksheet. So, it will surely demand lots of memory for the big process. Also, you are applying styles to each cell in the worksheet, which will also consume memory and the process would be bigger.

Anyways I can find the issue as you pointed out with your code. I have logged a ticket with an id: CELLSNET-40063. We will look into it if we can enhance the performance more.

Thank you.

Hi,

Please download and try this fix: Aspose.Cells for .NET v7.1.1.2

The issues you have found earlier (filed as CELLSNET-40063) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.