[]
Use this interface to configure workbook-level formula behavior, such as iterative calculation and its related limits. Obtain an instance from IExcelOptions.getFormulas().
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setEnableIterativeCalculation(true);
formulaOptions.setMaximumIterations(2);
IWorksheet sheet = workbook.getActiveSheet();
sheet.getRange("B1").setFormula("=A1+1");
sheet.getRange("C1").setFormula("=B1+1");
sheet.getRange("D1").setFormula("=C1+1");
sheet.getRange("A1").setFormula("=D1+1");
Object value = sheet.getRange("A1").getValue();
booleandoubleintvoidsetCalculationMode(CalculationMode calculationMode) voidsetEnableIterativeCalculation(boolean value) voidsetMaximumChange(double value) voidsetMaximumIterations(int value) When enabled, the workbook iteratively calculates formulas that contain circular references until the maximum number of iterations or maximum error threshold is reached.
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setEnableIterativeCalculation(true);
formulaOptions.setMaximumIterations(10);
boolean enabled = formulaOptions.getEnableIterativeCalculation();
true if iterative calculation is enabled for formulas with circular references; otherwise, false.When enabled, the workbook iteratively calculates formulas that contain circular references until the maximum number of iterations or maximum error threshold is reached.
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setEnableIterativeCalculation(true);
formulaOptions.setMaximumIterations(10);
value - true to enable iterative calculation for formulas with circular references; otherwise, false.When iterative calculation is enabled, formulas are recalculated until the maximum number of iterations is reached or the maximum error threshold is met.
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setEnableIterativeCalculation(true);
formulaOptions.setMaximumIterations(10);
int maximumIterations = formulaOptions.getMaximumIterations();
When iterative calculation is enabled, formulas are recalculated until the maximum number of iterations is reached or the maximum error threshold is met.
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setEnableIterativeCalculation(true);
formulaOptions.setMaximumIterations(10);
value - The maximum number of iterations allowed for iterative calculation.During iterative calculation, this value specifies the maximum difference allowed between the results of two consecutive iterations. Iteration stops when the difference is less than this value.
workbook.getOptions().getFormulas().setMaximumChange(0.01d);
double maximumChange = workbook.getOptions().getFormulas().getMaximumChange();
During iterative calculation, this value specifies the maximum difference allowed between the results of two consecutive iterations. Iteration stops when the difference is less than this value.
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
formulaOptions.setMaximumChange(0.01d);
value - The maximum error allowed for iterative calculation.This setting controls how Microsoft Excel recalculates formulas when the exported workbook is opened. It does not trigger calculation or control formula calculation in the current GcExcel workbook. To control calculation in the current workbook, use Workbook.setEnableCalculation(boolean).
workbook.getOptions().getFormulas().setCalculationMode(CalculationMode.Manual);
CalculationMode mode = workbook.getOptions().getFormulas().getCalculationMode();
if (mode == CalculationMode.Manual) {
workbook.save("path/to/manual-mode.xlsx");
}
This setting controls how Microsoft Excel recalculates formulas when the exported workbook is opened. It does not trigger calculation or control formula calculation in the current GcExcel workbook. To control calculation in the current workbook, use Workbook.setEnableCalculation(boolean).
IFormulaOptions formulaOptions = workbook.getOptions().getFormulas();
workbook.getActiveSheet().getRange("A1").setFormula("SUM(1, 2)");
formulaOptions.setCalculationMode(CalculationMode.Manual);
workbook.save("path/to/manual-mode.xlsx");
calculationMode - The calculation mode to store in the exported workbook. Must not be null.