calculate_formula method

calculate_formula

Calculates a formula.

Returns

Calculated formula result.

def calculate_formula(self, formula):
    ...
ParameterTypeDescription
formulastrFormula to be calculated.

calculate_formula

Calculates a formula expression directly.

Returns

Calculated result of given formula. The returned object may be of possible types of Cell.value, or ReferredArea.

def calculate_formula(self, formula, opts):
    ...
ParameterTypeDescription
formulastrFormula to be calculated.
optsCalculationOptionsOptions for calculating formula

Remarks

The formula will be calculated just like it has been set to cell A1. And the formula will be taken as normal formula. If you need the formula be calculated as an array formula and to get an array for the calculated result, please use Worksheet.calculate_array_formula instead.

calculate_formula

Calculates all formulas in this worksheet.

def calculate_formula(self, options, recursive):
    ...
ParameterTypeDescription
optionsCalculationOptionsOptions for calculation
recursiveboolTrue means if the worksheet’ cells depend on the cells of other worksheets,
the dependent cells in other worksheets will be calculated too.
False means all the formulas in the worksheet have been calculated and the values are right.

calculate_formula

Calculates a formula expression directly.

Returns

Calculated result of given formula. The returned object may be of possible types of Cell.value, or ReferredArea.

def calculate_formula(self, formula, p_opts, c_opts, base_cell_row, base_cell_column, calculation_data):
    ...
ParameterTypeDescription
formulastrFormula to be calculated.
p_optsFormulaParseOptionsOptions for parsing formula.
c_optsCalculationOptionsOptions for calculating formula.
base_cell_rowintThe row index of the base cell.
base_cell_columnintThe column index of the base cell.
calculation_dataCalculationDataThe calculation data. It is used for the situation
that user needs to calculate some static formulas when implementing custom calculation engine.
For such kind of situation, user needs to specify it with the calculation data provided
for AbstractCalculationEngine.calculate.

Remarks

The formula will be calculated just like it has been set to the specified base cell. And the formula will be taken as normal formula. If you need the formula be calculated as an array formula and to get an array for the calculated result, please use Worksheet.calculate_array_formula instead.

See Also