Getting the Calculation Instance
getInstance()
Get a singleton instance of the Calculation engine.$spreadsheet(Spreadsheet|null): Optional spreadsheet object to work with
Calculation instance
Calculation Methods
calculate()
Calculate the value of a cell.$cell(Cell|null): The cell to calculate
calculateCellValue()
Calculate a cell value with optional debug log reset.$cell(Cell|null): The cell to calculate$resetLog(bool): Whether to reset the debug log (default: true)
calculateFormula()
Calculate a formula string directly.$formula(string): The formula to calculate (with or without leading =)$cellID(string|null): Optional cell reference for context$cell(Cell|null): Optional cell object for context
parseFormula()
Parse a formula into its component tokens without evaluating it.$formula(string): The formula to parse
array|bool - Array of formula tokens or false on failure
Calculation Cache
The calculation engine includes a cache to improve performance when recalculating formulas.enableCalculationCache()
Enable the calculation cache.disableCalculationCache()
Disable the calculation cache.clearCalculationCache()
Clear all cached calculation results.getCalculationCacheEnabled()
Check if calculation cache is enabled.bool - True if cache is enabled
Example:
clearCalculationCacheForWorksheet()
Clear cache for a specific worksheet.$worksheetName(string): Name of the worksheet to clear cache for
Branch Pruning
Branch pruning optimizes conditional formula evaluation by skipping unnecessary branches.enableBranchPruning()
Enable branch pruning optimization.disableBranchPruning()
Disable branch pruning optimization.getBranchPruningEnabled()
Check if branch pruning is enabled.bool - True if branch pruning is enabled
Example:
Array Return Type
setInstanceArrayReturnType()
Set how array formulas should return results.$returnType(string): One of:Calculation::RETURN_ARRAY_AS_VALUE- Return first element onlyCalculation::RETURN_ARRAY_AS_ERROR- Return error for arraysCalculation::RETURN_ARRAY_AS_ARRAY- Return full array
bool - Success or failure
getInstanceArrayReturnType()
Get current array return type setting.string - Current array return type
Function Information
isImplemented()
Check if a function is implemented.$function(string): Function name to check
bool - True if function is implemented
getImplementedFunctionNames()
Get list of all implemented function names.array - Array of function names
Example:
Error Handling
setSuppressFormulaErrors()
Control whether formula errors should be suppressed.$suppressFormulaErrors(bool): Whether to suppress errors
Calculation - Returns self for method chaining
getSuppressFormulaErrors()
Check if formula errors are being suppressed.bool - True if errors are suppressed
Debug Logging
getDebugLog()
Get the debug logger instance.Logger - The debug logger instance
Example:
Cell Range Extraction
extractCellRange()
Extract values from a cell range.$range(string): Cell range (e.g., ‘A1:B10’)$worksheet(Worksheet|null): Optional worksheet object$resetLog(bool): Whether to reset debug log (default: true)$createCell(bool): Whether to create cells if they don’t exist (default: false)
array - Array of cell values
extractNamedRange()
Extract values from a named range.$range(string): Named range name$worksheet(Worksheet|null): Optional worksheet object$resetLog(bool): Whether to reset debug log (default: true)
string|array - Range definition or array of values

