CalculateFormula throwing stackoverflow error

Hello,


We’ve run into an issue where making a call into CalculateFormula ends up causing a stack overflow error. I’ve tried using the CalculationOptions class, but this also fails.

I’ve attached a sample project demonstrating this behavior. Please let me know if there is anything else you need from me to investigate.

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells.

We tested your sample project with the latest version: Aspose.Cells
for .NET v8.6.1.2
and it also threw the exception. However, the exception was little different.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-44064 - CalculateFormula throws exception on source xlsm

I have also shown the exception detail below.

Exception
Aspose.Cells.CellsException was unhandled by user code
HResult=-2146232832
Message=Error in calculating Cell[[7]Penetration!AS107]
Source=Aspose.Cells
StackTrace:
at . . ( , )
at . . ( , )
at . . ( , Boolean )
at . .Calculate( )
at . . ()
at . . ( )
at Aspose.Cells.Workbook.CalculateFormula(CalculationOptions options)
at WebApplication2.Default.Go_Click(Object sender, EventArgs e) in d:\Downloads\sample\WebApplication2\Default.aspx.cs:line 56
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.IndexOutOfRangeException
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=Aspose.Cells
StackTrace:
at . . . . ( )
at . . . . ( , , )
at . . ( , )
at . . ( , Int32 , Int32 , CellArea )
at . . ( , Int32 , Int32 )
at . . ( , Boolean )
at . . ( , )
at . . ( )
at . .Calculate( )
at . . ( )
at . . ( )
at . .Calculate( )
at . . ( )
at . . ( , Boolean )
at . . ( , )
at . . ( , Boolean )
at . . (Int32 , , Boolean )
at . . ( , Boolean )
at . . ( , )
at . .Process( , )
at . . ( , )
InnerException:

Hi,

Thanks for using Aspose.Cells.

When we calculated the workbook in common console application, we cannot find any issue. We think maybe it is issue of IIS for too small stack size.

What’s the environment for getting such kind of issue(StackOverflowException)? If it is on IIS server, please see the document at

(FAQ|Documentation)

Hi,

Thanks for using Aspose.Cells.

We have fixed the similar issues in the recent version. Please download and try the latest version: Aspose.Cells
for .NET v8.6.3.3
your issue should be fixed with it too.

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

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Aspose Team,

We have a workbook with 16 worksheet and we have 300 rows of data in one worksheet 1 with 6 and 7 digit numbers .

The numbers from Worksheet 1 will be used in other worksheets for formula calculation.

We are getting Stack Overflow error in Workbook.Calculateformula .

Looks like because of 6 and 7 digit numbers Workbook.Calculateformula limit is getting exceeded and Aspose is crashing internally.

When I try to change the numbers to 3 - 4 digits number it works fine.

Note : All excel operations is done in a windows service , because of this issue the service is stopped.

Version used - 8.8.0.0 and 17.4.5

Please let us know if a fix is available for this issue.

Hi gsanthosh,


We recommend you to kindly try our latest version/fix: Aspose.Cells for .NET v17.6 if it makes any difference. Well, the StackOverflowException might occur when calculating formulas with large volume of values. By using relatively smaller stack size settings, the calculation can be succeeded. You may try to add a line of code (in bold) before calculating formulas to your code:
e.g
Sample code:

Workbook workbook = new Workbook(strFilePath);
workbook.Settings.CalcStackSize = 30;
workbook.CalculateFormula();

Please note WorkbookSettings.CalcStackSize specifies the stack size for calculating cells recursively. The large value for this size will give better performance when there are lots of cells need to be calculated recursively. On the other hand, larger value will raise the risk of StackOverflowException. If a user gets StackOverflowException when calculating formulas, this value should be decreased.

Thank you.