\PHPExcel_Calculation

PHPExcel_Calculation (Multiton)

Summary

Methods
Properties
Constants
__destruct()
getInstance()
unsetInstance()
flushInstance()
getDebugLog()
__clone()
getTRUE()
getFALSE()
setArrayReturnType()
getArrayReturnType()
getCalculationCacheEnabled()
setCalculationCacheEnabled()
enableCalculationCache()
disableCalculationCache()
clearCalculationCache()
clearCalculationCacheForWorksheet()
renameCalculationCacheForWorksheet()
getLocale()
setLocale()
_translateSeparator()
_translateFormulaToLocale()
_translateFormulaToEnglish()
_localeFunc()
_wrapResult()
_unwrapResult()
calculate()
calculateCellValue()
parseFormula()
calculateFormula()
getValueFromCache()
saveValueToCache()
_calculateFormulaValue()
_getMatrixDimensions()
extractCellRange()
extractNamedRange()
isImplemented()
listFunctions()
listAllFunctionNames()
listFunctionNames()
$suppressFormulaErrors
$formulaError
$cyclicFormulaCount
$_localeBoolean
CALCULATION_REGEXP_NUMBER
CALCULATION_REGEXP_STRING
CALCULATION_REGEXP_OPENBRACE
CALCULATION_REGEXP_FUNCTION
CALCULATION_REGEXP_CELLREF
CALCULATION_REGEXP_NAMEDRANGE
CALCULATION_REGEXP_ERROR
RETURN_ARRAY_AS_ERROR
RETURN_ARRAY_AS_VALUE
RETURN_ARRAY_AS_ARRAY
_raiseFormulaError()
No protected properties found
N/A
__construct()
_loadLocales()
_translateFormula()
_checkMatrixOperands()
_resizeMatricesShrink()
_resizeMatricesExtend()
_showValue()
_showTypeDetails()
_convertMatrixReferences()
_mkMatrix()
_parseFormula()
_dataTestReference()
_processTokenStack()
_validateBinaryOperand()
_executeBinaryComparisonOperation()
strcmpLowercaseFirst()
_executeNumericBinaryOperation()
$returnArrayAsType
$_instance
$_workbook
$_workbookSets
$_calculationCache
$_calculationCacheEnabled
$_operators
$_binaryOperators
$debugLog
$_cyclicReferenceStack
$_cyclicFormulaCount
$_cyclicFormulaCell
$_savedPrecision
$_localeLanguage
$_validLocaleLanguages
$_localeArgumentSeparator
$_localeFunctions
$_ExcelConstants
$_PHPExcelFunctions
$_controlFunctions
$functionReplaceFromExcel
$functionReplaceToLocale
$functionReplaceFromLocale
$functionReplaceToExcel
$_operatorAssociativity
$_comparisonOperators
$_operatorPrecedence
N/A

Constants

CALCULATION_REGEXP_NUMBER

CALCULATION_REGEXP_NUMBER

CALCULATION_REGEXP_STRING

CALCULATION_REGEXP_STRING

CALCULATION_REGEXP_OPENBRACE

CALCULATION_REGEXP_OPENBRACE

CALCULATION_REGEXP_FUNCTION

CALCULATION_REGEXP_FUNCTION

CALCULATION_REGEXP_CELLREF

CALCULATION_REGEXP_CELLREF

CALCULATION_REGEXP_NAMEDRANGE

CALCULATION_REGEXP_NAMEDRANGE

CALCULATION_REGEXP_ERROR

CALCULATION_REGEXP_ERROR

RETURN_ARRAY_AS_ERROR

RETURN_ARRAY_AS_ERROR

constants

RETURN_ARRAY_AS_VALUE

RETURN_ARRAY_AS_VALUE

RETURN_ARRAY_AS_ARRAY

RETURN_ARRAY_AS_ARRAY

Properties

$suppressFormulaErrors

$suppressFormulaErrors : boolean

Flag to determine how formula errors should be handled If true, then a user error will be triggered If false, then an exception will be thrown

Type

boolean

$formulaError

$formulaError : string

Error message for any error that was raised/thrown by the calculation engine

Type

string

$cyclicFormulaCount

$cyclicFormulaCount : integer

Number of iterations for cyclic formulae

Type

integer

$_localeBoolean

$_localeBoolean : array<mixed,string>

Locale-specific translations for Excel constants (True, False and Null)

Type

array<mixed,string>

$returnArrayAsType

$returnArrayAsType : 

Type

$_workbook

$_workbook : \PHPExcel

Instance of the workbook this Calculation Engine is using

Type

\PHPExcel

$_workbookSets

$_workbookSets : array<mixed,\PHPExcel_Calculation>

List of instances of the calculation engine that we've instantiated for individual workbooks

Type

array<mixed,\PHPExcel_Calculation>

$_calculationCache

$_calculationCache : array

Calculation cache

Type

array

$_calculationCacheEnabled

$_calculationCacheEnabled : boolean

Calculation cache enabled

Type

boolean

$_operators

$_operators : array

List of operators that can be used within formulae The true/false value indicates whether it is a binary operator or a unary operator

Type

array

$_binaryOperators

$_binaryOperators : array

List of binary operators (those that expect two operands)

Type

array

$_cyclicReferenceStack

$_cyclicReferenceStack : array

An array of the nested cell references accessed by the calculation engine, used for the debug log

Type

array — of string

$_cyclicFormulaCount

$_cyclicFormulaCount : integer

Current iteration counter for cyclic formulae If the value is 0 (or less) then cyclic formulae will throw an exception, otherwise they will iterate to the limit defined here before returning a result

Type

integer

$_cyclicFormulaCell

$_cyclicFormulaCell : 

Type

$_savedPrecision

$_savedPrecision : integer

Precision used for calculations

Type

integer

$_localeLanguage

$_localeLanguage : string

The current locale setting

Type

string

$_validLocaleLanguages

$_validLocaleLanguages : array<mixed,string>

List of available locale settings Note that this is read for the locale subdirectory only when requested

Type

array<mixed,string>

$_localeArgumentSeparator

$_localeArgumentSeparator : string

Locale-specific argument separator for function arguments

Type

string

$_localeFunctions

$_localeFunctions : 

Type

$_ExcelConstants

$_ExcelConstants : array<mixed,string>

Excel constant string translations to their PHP equivalents Constant conversion from text name/value to actual (datatyped) value

Type

array<mixed,string>

$_PHPExcelFunctions

$_PHPExcelFunctions : 

Type

$_controlFunctions

$_controlFunctions : 

Type

$functionReplaceFromExcel

$functionReplaceFromExcel : 

Type

$functionReplaceToLocale

$functionReplaceToLocale : 

Type

$functionReplaceFromLocale

$functionReplaceFromLocale : 

Type

$functionReplaceToExcel

$functionReplaceToExcel : 

Type

$_operatorAssociativity

$_operatorAssociativity : 

Type

$_comparisonOperators

$_comparisonOperators : 

Type

$_operatorPrecedence

$_operatorPrecedence : 

Type

Methods

__destruct()

__destruct() 

getInstance()

getInstance(\PHPExcel  $workbook = NULL) : \PHPExcel_Calculation

Get an instance of this class

Parameters

\PHPExcel $workbook

Injected workbook for working with a PHPExcel object, or NULL to create a standalone claculation engine

Returns

\PHPExcel_Calculation

unsetInstance()

unsetInstance(\PHPExcel  $workbook = NULL) 

Unset an instance of this class

Parameters

\PHPExcel $workbook

Injected workbook identifying the instance to unset

flushInstance()

flushInstance() : null

Flush the calculation cache for any existing instance of this class but only if a PHPExcel_Calculation instance exists

Returns

null

getDebugLog()

getDebugLog() : \PHPExcel_CalcEngine_Logger

Get the debuglog for this claculation engine instance

Returns

\PHPExcel_CalcEngine_Logger

__clone()

__clone() 

__clone implementation. Cloning should not be allowed in a Singleton!

Throws

\PHPExcel_Calculation_Exception

getTRUE()

getTRUE() : string

Return the locale-specific translation of TRUE

Returns

string —

locale-specific translation of TRUE

getFALSE()

getFALSE() : string

Return the locale-specific translation of FALSE

Returns

string —

locale-specific translation of FALSE

setArrayReturnType()

setArrayReturnType(string  $returnType) : boolean

Set the Array Return Type (Array or Value of first element in the array)

Parameters

string $returnType

Array return type

Returns

boolean —

Success or failure

getArrayReturnType()

getArrayReturnType() : string

Return the Array Return Type (Array or Value of first element in the array)

Returns

string —

$returnType Array return type

getCalculationCacheEnabled()

getCalculationCacheEnabled() : boolean

Is calculation caching enabled?

Returns

boolean

setCalculationCacheEnabled()

setCalculationCacheEnabled(boolean  $pValue = TRUE) 

Enable/disable calculation cache

Parameters

boolean $pValue

enableCalculationCache()

enableCalculationCache() 

Enable calculation cache

disableCalculationCache()

disableCalculationCache() 

Disable calculation cache

clearCalculationCache()

clearCalculationCache() 

Clear calculation cache

clearCalculationCacheForWorksheet()

clearCalculationCacheForWorksheet(string  $worksheetName) 

Clear calculation cache for a specified worksheet

Parameters

string $worksheetName

renameCalculationCacheForWorksheet()

renameCalculationCacheForWorksheet(string  $fromWorksheetName, string  $toWorksheetName) 

Rename calculation cache for a specified worksheet

Parameters

string $fromWorksheetName
string $toWorksheetName

getLocale()

getLocale() : string

Get the currently defined locale code

Returns

string

setLocale()

setLocale(string  $locale = 'en_us') : boolean

Set the locale code

Parameters

string $locale

The locale to use for formula translation

Returns

boolean

_translateSeparator()

_translateSeparator(  $fromSeparator,   $toSeparator,   $formula,   $inBraces) 

Parameters

$fromSeparator
$toSeparator
$formula
$inBraces

_translateFormulaToLocale()

_translateFormulaToLocale(  $formula) 

Parameters

$formula

_translateFormulaToEnglish()

_translateFormulaToEnglish(  $formula) 

Parameters

$formula

_localeFunc()

_localeFunc(  $function) 

Parameters

$function

_wrapResult()

_wrapResult(mixed  $value) : mixed

Wrap string values in quotes

Parameters

mixed $value

Returns

mixed

_unwrapResult()

_unwrapResult(mixed  $value) : mixed

Remove quotes used as a wrapper to identify string values

Parameters

mixed $value

Returns

mixed

calculate()

calculate(\PHPExcel_Cell  $pCell = NULL) : mixed

Calculate cell value (using formula from a cell ID) Retained for backward compatibility

Parameters

\PHPExcel_Cell $pCell

Cell to calculate

Throws

\PHPExcel_Calculation_Exception

Returns

mixed

calculateCellValue()

calculateCellValue(\PHPExcel_Cell  $pCell = NULL, Boolean  $resetLog = TRUE) : mixed

Calculate the value of a cell formula

Parameters

\PHPExcel_Cell $pCell

Cell to calculate

Boolean $resetLog

Flag indicating whether the debug log should be reset or not

Throws

\PHPExcel_Calculation_Exception

Returns

mixed

parseFormula()

parseFormula(string  $formula) : array

Validate and parse a formula string

Parameters

string $formula

Formula to parse

Throws

\PHPExcel_Calculation_Exception

Returns

array

calculateFormula()

calculateFormula(string  $formula, string  $cellID = NULL, \PHPExcel_Cell  $pCell = NULL) : mixed

Calculate the value of a formula

Parameters

string $formula

Formula to parse

string $cellID

Address of the cell to calculate

\PHPExcel_Cell $pCell

Cell to calculate

Throws

\PHPExcel_Calculation_Exception

Returns

mixed

getValueFromCache()

getValueFromCache(  $worksheetName,   $cellID,   $cellValue) 

Parameters

$worksheetName
$cellID
$cellValue

saveValueToCache()

saveValueToCache(  $worksheetName,   $cellID,   $cellValue) 

Parameters

$worksheetName
$cellID
$cellValue

_calculateFormulaValue()

_calculateFormulaValue(string  $formula, string  $cellID = null, \PHPExcel_Cell  $pCell = null) : mixed

Parse a cell formula and calculate its value

Parameters

string $formula

The formula to parse and calculate

string $cellID

The ID (e.g. A3) of the cell that we are calculating

\PHPExcel_Cell $pCell

Cell to calculate

Throws

\PHPExcel_Calculation_Exception

Returns

mixed

_getMatrixDimensions()

_getMatrixDimensions(  $matrix) : array

Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0

Parameters

$matrix

Returns

array —

An array comprising the number of rows, and number of columns

extractCellRange()

extractCellRange(  $pRange = 'A1', \PHPExcel_Worksheet  $pSheet = NULL, boolean  $resetLog = TRUE) : mixed

Extract range values

Parameters

$pRange
\PHPExcel_Worksheet $pSheet

Worksheet

boolean $resetLog

Flag indicating whether calculation log should be reset or not

Throws

\PHPExcel_Calculation_Exception

Returns

mixed —

Array of values in range if range contains more than one element. Otherwise, a single value is returned.

extractNamedRange()

extractNamedRange(  $pRange = 'A1', \PHPExcel_Worksheet  $pSheet = NULL, boolean  $resetLog = TRUE) : mixed

Extract range values

Parameters

$pRange
\PHPExcel_Worksheet $pSheet

Worksheet

boolean $resetLog

Flag indicating whether calculation log should be reset or not

Throws

\PHPExcel_Calculation_Exception

Returns

mixed —

Array of values in range if range contains more than one element. Otherwise, a single value is returned.

isImplemented()

isImplemented(string  $pFunction = '') : boolean

Is a specific function implemented?

Parameters

string $pFunction

Function Name

Returns

boolean

listFunctions()

listFunctions() : array

Get a list of all implemented functions as an array of function objects

Returns

array —

of PHPExcel_Calculation_Function

listAllFunctionNames()

listAllFunctionNames() : array

Get a list of all Excel function names

Returns

array

listFunctionNames()

listFunctionNames() : array

Get a list of implemented Excel function names

Returns

array

_raiseFormulaError()

_raiseFormulaError(  $errorMessage) 

Parameters

$errorMessage

__construct()

__construct(\PHPExcel  $workbook = NULL) 

Parameters

\PHPExcel $workbook

_loadLocales()

_loadLocales() 

_translateFormula()

_translateFormula(  $from,   $to,   $formula,   $fromSeparator,   $toSeparator) 

Parameters

$from
$to
$formula
$fromSeparator
$toSeparator

_checkMatrixOperands()

_checkMatrixOperands(  $operand1,   $operand2, integer  $resize = 1) 

Ensure that paired matrix operands are both matrices and of the same size

Parameters

$operand1
$operand2
integer $resize

Flag indicating whether the matrices should be resized to match and (if so), whether the smaller dimension should grow or the larger should shrink. 0 = no resize 1 = shrink to fit 2 = extend to fit

_resizeMatricesShrink()

_resizeMatricesShrink(  $matrix1,   $matrix2, integer  $matrix1Rows, integer  $matrix1Columns, integer  $matrix2Rows, integer  $matrix2Columns) 

Ensure that paired matrix operands are both matrices of the same size

Parameters

$matrix1
$matrix2
integer $matrix1Rows

Row size of first matrix operand

integer $matrix1Columns

Column size of first matrix operand

integer $matrix2Rows

Row size of second matrix operand

integer $matrix2Columns

Column size of second matrix operand

_resizeMatricesExtend()

_resizeMatricesExtend(  $matrix1,   $matrix2, integer  $matrix1Rows, integer  $matrix1Columns, integer  $matrix2Rows, integer  $matrix2Columns) 

Ensure that paired matrix operands are both matrices of the same size

Parameters

$matrix1
$matrix2
integer $matrix1Rows

Row size of first matrix operand

integer $matrix1Columns

Column size of first matrix operand

integer $matrix2Rows

Row size of second matrix operand

integer $matrix2Columns

Column size of second matrix operand

_showValue()

_showValue(mixed  $value) : mixed

Format details of an operand for display in the log (based on operand type)

Parameters

mixed $value

First matrix operand

Returns

mixed

_showTypeDetails()

_showTypeDetails(mixed  $value) : mixed

Format type and details of an operand for display in the log (based on operand type)

Parameters

mixed $value

First matrix operand

Returns

mixed

_convertMatrixReferences()

_convertMatrixReferences(  $formula) 

Parameters

$formula

_mkMatrix()

_mkMatrix() 

_parseFormula()

_parseFormula(  $formula, \PHPExcel_Cell  $pCell = NULL) 

Parameters

$formula
\PHPExcel_Cell $pCell

_dataTestReference()

_dataTestReference(  $operandData) 

Parameters

$operandData

_processTokenStack()

_processTokenStack(  $tokens,   $cellID = NULL, \PHPExcel_Cell  $pCell = NULL) 

Parameters

$tokens
$cellID
\PHPExcel_Cell $pCell

_validateBinaryOperand()

_validateBinaryOperand(  $cellID,   $operand,   $stack) 

Parameters

$cellID
$operand
$stack

_executeBinaryComparisonOperation()

_executeBinaryComparisonOperation(  $cellID,   $operand1,   $operand2,   $operation,   $stack,   $recursingArrays = FALSE) 

Parameters

$cellID
$operand1
$operand2
$operation
$stack
$recursingArrays

strcmpLowercaseFirst()

strcmpLowercaseFirst(string  $str1, string  $str2) : integer

Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters

Parameters

string $str1
string $str2

Returns

integer

_executeNumericBinaryOperation()

_executeNumericBinaryOperation(  $cellID,   $operand1,   $operand2,   $operation,   $matrixFunction,   $stack) 

Parameters

$cellID
$operand1
$operand2
$operation
$matrixFunction
$stack