Free Support Forum - aspose.com

Problem in creating a image using aspose cells

hi,
I am working with C#.NET 2005 windows application.
this code is in .cs file
I am trying to create 100 images and xls files. i have written the following code.
this is a sample code . I am basically trying to evaluate aspose cells.
Code:
//Description : first i have created a array d of 3,100
double[,] d = new double[3,100];
d.SetValue(100000, 0, 0);
d.SetValue(20, 1, 0);
d.SetValue(10, 2, 0);
int chartIndex;
System.Drawing.Bitmap bitmap;
for (int i = 1; i < 100; i++)
{
Workbook workbook = new Workbook();


//Adding a new worksheet to the Workbook object
int sheetIndex = workbook.Worksheets.Add();

Worksheet worksheet = workbook.Worksheets[sheetIndex];

//Adding a sample value to “A3” cell
worksheet.Cells.ImportArray(d, 0, 0);
//Set the formula for cells
worksheet.Cells[0, i].Formula = “= (” + worksheet.Cells[0, i - 1].Name + “-” + worksheet.Cells[1, i - 1].Name + “-” + worksheet.Cells[2, i - 1].Name + “)”;
worksheet.Cells[1, i].Formula = “= (” + worksheet.Cells[1, i - 1].Name + “+” + 5 + “)”;
worksheet.Cells[2, i].Formula = “= (” + worksheet.Cells[2, i - 1].Name + “+” + 2 + “)”;
workbook.CalculateFormula();
//update the new values in array
d.SetValue(worksheet.Cells[0, i].Value, 0, i);
d.SetValue(worksheet.Cells[1, i].Value, 1, i);
d.SetValue(worksheet.Cells[2, i].Value, 2, i);
chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 15, 5);

Chart chart = worksheet.Charts[chartIndex];
chart.NSeries.Add(“A1:” + worksheet.Cells[2, i].Name, true);
bitmap = chart.ToImage();
bitmap.Save(“F:/TestApose/”+ i+".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
workbook.Save(“F:/TestApose/” + i + “.xls”, FileFormatType.Default);

}

MessageBox.Show(“Complet”);
}
this is the code i had written to calculate the values of cells and this is working fine upto 55 images and xls files.
But for the 56th image creation it is giving error as null reference
Exact error details : NullReferenceException was Unhandled.
Objet reference not set to an instance of an objet


Hi,

Thanks for considering Aspose.

Which version of Aspose.Cells for .Net you are using. And are you using evalution version or licensed version of Aspose.Cells?

Thank you

Hi,

I am using 4.3.0 Aspose Version for .NET and actually now i am using evaluation copy for just evaluating whether we can use this product in our code or not.Infact we are planning to purchase aspose cells, pdf and pdf kit as soon as possible.

thank you,



Hi,

We have found the problem. We will fix it soon.

In the current version, there is no problem if the number of ASeries is less than 56.

Hi,

Please try this fix.

Hi,

It worked. Thanx a lot!!

Hi,
Can i create multiple tasks using aspose.cells ??
Suppose i want to calculate 5 different worksheets at a time. each of them will have their own formula for each cell. so when i say ‘workbook.calculate()’ so can i do this for each worksheet at same time???

Thanx,

-Shailesh

Hi,

We have to calculate all formuals in the worbook when you call workbook.CalculateFormula() method.

In the net version, we do not support to only calculate the formulas in a worksheet.