Free Support Forum - aspose.com

Let Excel recalculate forumla on workbook open

Hello guys,

is there any way I can tell Excel to recalculate all Formula when the user opens the workbook? I’m currently converting my document generation process to Aspose.Cells at the moment. Before that we’ve used Apache POI. There was a API-Call setForceFormulaRecalculation(Boolean) after calling that and opening the document in Excel every formula was recalculated by Excel.
Is there anything comparable in Aspose.Cells?

Best Regards
Jan

Hi,

Yes, you can use this code to set the formula calculation of workbook on opening using Aspose.Cells for Java.

Java


//Create a new workbook
Workbook workbook = new Workbook();

//Calculate formula on open
workbook.getWorkbookSettings().setCalculateOnOpen(true);

//Save the workbook
workbook.save(“F:\Shak-Data-RW\Downloads\Files\output.xlsx”, FileFormatType.XLSX);

Also, there is a enumeration CalculationMode which has following values

  1. CalculationMode.AUTOMATIC
  2. CalculationMode.MANUAL

The following code sets the calculation mode to manually.

Java

//Create a new workbook
Workbook workbook = new Workbook();

//Set calculation mode to manual
workbook.getWorkbookSettings().setCalculationMode(CalculationMode.MANUAL);

//Save the workbook
workbook.save(“F:\Shak-Data-RW\Downloads\Files\output.xlsx”, FileFormatType.XLSX);