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

Free Support Forum - aspose.com

How the calculation engine works

I’m using the .NET Cells package and trying to get a better understanding of how the calculation engine works.

When I create a new workbook and populate it with formulas, values, etc. is the calculation engine always running? Meaning after every write the engine recalculates the workbook? Or do I have to manually tell it to do that? How about when I save that workbook? What classes/settings/method calls are involved with calculation?

When I open an existing workbook, does the calculation engine run? Or do I have to tell it to run?


Thanks for your query.

Well, Aspose.Cells has its own and independent formula calculation engine. By default, when you instantiate a workbook and input values/formulas or read an existing file or even save the file via Aspose.Cells APIs, the formula calculation engine does not run. But when you explicitly call Workbook.CalculateFomrula or Worksheet.CalculateFormula or Cell.Calculate() method, the calculation engine processes/reprocesses the spreadsheet/sheet cells. See the documents for your reference:

Also, see the documents in the section for your further reference:

Please note, when you save the file in Ms Excel file format, you do not need to calculate formulas before saving via Aspose.Cells APIs as MS Excel by default do that (by default Calculation Options are set to “Automatic”). But when you render to image or PDF file format, you need to call the method (e.g Workbook.CalculateFormula() method) before saving to image or PDF file format.

Moreover, you may specify calculation mode i.e., set the calculation mode of MS Excel if it will calculate the formulas automatically when you open the output file into it or not. Also, you may specify if you need to recalculate formulas on opening or saving the file accordingly, see the following lines of code for your reference:
Sample code:

workbook.Settings.CalcMode = CalcModeType.Automatic;
workbook.Settings.ReCalculateOnOpen = true;

Hope, this helps a bit.