Hello,
I’m using Aspose.Cells for .NET 7.1.2.0. A particular workbook that I’m working with contains a large series of concatenation formulas. I have code that inserts rows then tries to calculate the sheet. It seems like this code runs fine in some 64bit environments, but in 32bit, the call to CalculateFormula() throws an error, at which point the process terminates, before my code has a chance to log the error or handle it in any way. Stepping through with a debugger, I can see that the following error occurs:
An unhandled exception of type ‘System.StackOverflowException’ occurred in Aspose.Cells.dll
[When the problem happens in the context of my web application, the error is reported as occurring in mscorlib.dll.]
I understand that there may be limits to the number of levels of formulas than can be processed, but is there any way that it could be made to fail more gracefully, in a way where the error could be trapped and handled? The code I’m using is here; the spreadsheet is attached.
void IssueWithCalculateCausesOverflow()
{
try
{
var filepath = string.Format("{0}CalculateOverflow5.xls", TestHelper.Folder);
var workbook = new Workbook(filepath, new LoadOptions(LoadFormat.Excel97To2003));
var worksheet = workbook.Worksheets[0];
worksheet.Cells.InsertRows(17, 2);
worksheet.Workbook.CalculateFormula(true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadKey();
}
}
Hi,
Thanks for your posting and using Aspose.Cells for .NET.
We have recently fixed this error.
Please download and use the latest version:
Aspose.Cells
for .NET v7.3.2.1
It should work fine.
I have tested with the above version and found no issue with it. Below is my sample test code.
C#
string filepath = @“F:\Shak-Data-RW\Downloads\CalculateOverflow5.xls”;
var workbook = new Workbook(filepath, new LoadOptions(LoadFormat.Excel97To2003));
var worksheet = workbook.Worksheets[0];
worksheet.Cells.InsertRows(17, 2);
worksheet.Workbook.CalculateFormula(true);
Thank you for your quick response. I tried the newer version and there is no difference. See attached screenshot. The behaviour I described earlier is not exactly correct. I am running on a 64bit (Win7) machine with these results:
- console app: works when platform target is x86 or Any CPU; fails when x64
- web app running in IIS7 Classic mode: works when “Enable 32-Bit Applications” is set to false for the app pool; fails when it is set to true
Hi,
VS.NET
2008/2010 with v7.3.2.1, zip it and post it here. We will simply run your project and it will help us to trace the issue accurately, so that we could log your issue to figure it out soon.Here is a console app which I believe produces the error. I’m more concerned about the error in the web app, but that’s a little more difficult to package up. I’m assuming it’s the same issue.
Hi,
VS.NET
project whose target platform is set to x64bit.Hi,
C#
private HttpPostedFileBase file;
[HttpPost]
public ActionResult Index(HttpPostedFileBase file, string mode)
{
this.file = file;
Thread t = new Thread(Calc, 1048576);
t.Start();
t.Join();
return null;
}
private void Calc()
{
if (file != null && file.ContentLength > 0)
{
var wbkMain = new Workbook(file.InputStream);
wbkMain.CalculateFormula();
}
}