PHPExcel_Calculation

# Class: PHPExcel_Calculation

Source Location: /PHPExcel/Calculation.php

### Class Overview

PHPExcel_Calculation (Singleton)

#### Author(s):

#### Copyright:

- Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)

### Variables

- $cyclicFormulaCount
- $debugLog
- $echoDebugLog
- $formulaError
- $suppressFormulaErrors
- $writeDebugLog
- $_localeBoolean

### Constants

- CALCULATION_REGEXP_CELLREF
- CALCULATION_REGEXP_ERROR
- CALCULATION_REGEXP_FUNCTION
- CALCULATION_REGEXP_NAMEDRANGE
- CALCULATION_REGEXP_NUMBER
- CALCULATION_REGEXP_OPENBRACE
- CALCULATION_REGEXP_STRING
- RETURN_ARRAY_AS_ARRAY
- RETURN_ARRAY_AS_ERROR
- RETURN_ARRAY_AS_VALUE

### Methods

- __destruct
- calculate
- calculateCellValue
- calculateFormula
- clearCalculationCache
- disableCalculationCache
- enableCalculationCache
- extractCellRange
- extractNamedRange
- flushInstance
- getArrayReturnType
- getCalculationCacheEnabled
- getCalculationCacheExpirationTime
- getFALSE
- getInstance
- getLocale
- getTRUE
- isImplemented
- listAllFunctionNames
- listFunctionNames
- listFunctions
- parseFormula
- setArrayReturnType
- setCalculationCacheEnabled
- setCalculationCacheExpirationTime
- setLocale
- _calculateFormulaValue
- _getMatrixDimensions
- _localeFunc
- _raiseFormulaError
- _translateFormulaToEnglish
- _translateFormulaToLocale
- _translateSeparator
- _unwrapResult
- _wrapResult
- __clone

### Class Details

[line 62]
PHPExcel_Calculation (Singleton)

#### Tags:

copyright: | Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)

[ Top ]

### Class Variables

#### static $_localeBoolean = array( 'TRUE' => 'TRUE',
'FALSE' => 'FALSE',
'NULL' => 'NULL'
)

[line 226]

#### Tags:

access: | public

Type: | mixed

[ Top ]

#### $cyclicFormulaCount = 0

[line 215]

#### Tags:

access: | public

Type: | mixed

[ Top ]

#### $debugLog = array()

[line 212]

The debug log generated by the calculation engine

#### Tags:

var: | of string
access: | public

Type: | array

[ Top ]

#### $echoDebugLog = false

[line 193]

Flag to determine whether a debug log should be echoed by the calculation engine

If true, then a debug log will be echoed If false, then a debug log will not be echoed A debug log can only be echoed if it is generated

#### Tags:

access: | public

Type: | boolean

[ Top ]

#### $formulaError = null

[line 170]

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

#### Tags:

access: | public

Type: | string

[ Top ]

#### $suppressFormulaErrors = false

[line 161]

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

#### Tags:

access: | public

Type: | boolean

[ Top ]

#### $writeDebugLog = false

[line 181]

Flag to determine whether a debug log should be generated by the calculation engine If true, then a debug log will be generated If false, then a debug log will not be generated

#### Tags:

access: | public

Type: | boolean

[ Top ]

### Class Methods

### static method flushInstance [line 1728]

`static null flushInstance( )`

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

#### Tags:

access: | public

[ Top ]

### static method getArrayReturnType [line 1790]

`static string getArrayReturnType( )`

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

#### Tags:

return: | Array return type
access: | public

[ Top ]

### static method getFALSE [line 1762]

`static string getFALSE( )`

Return the locale-specific translation of FALSE

#### Tags:

return: | locale-specific translation of FALSE
access: | public

[ Top ]

### static method getInstance [line 1712]

`static PHPExcel_Calculation getInstance( )`

Get an instance of this class

#### Tags:

access: | public

[ Top ]

### static method getTRUE [line 1752]

`static string getTRUE( )`

Return the locale-specific translation of TRUE

#### Tags:

return: | locale-specific translation of TRUE
access: | public

[ Top ]

### static method setArrayReturnType [line 1773]

`static boolean setArrayReturnType( string $returnType)`

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

#### Tags:

return: | Success or failure
access: | public

#### Parameters:

string | $returnType | Array return type

[ Top ]

### static method _getMatrixDimensions [line 2391]

`static array _getMatrixDimensions( mixed &$matrix)`

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

#### Tags:

return: | An array comprising the number of rows, and number of columns
access: | public

#### Parameters:

mixed | &$matrix | matrix operand

[ Top ]

### static method _localeFunc [line 2056]

`static void _localeFunc( $function)`

#### Tags:

access: | public

#### Parameters:

| $function |

[ Top ]

### static method _translateSeparator [line 1951]

`static void _translateSeparator( $fromSeparator, $toSeparator, $formula, &$inBraces)`

#### Tags:

access: | public

#### Parameters:

| $fromSeparator |
| $toSeparator |
| $formula |
| &$inBraces |

[ Top ]

### static method _unwrapResult [line 2101]

`static mixed _unwrapResult( mixed $value)`

Remove quotes used as a wrapper to identify string values

#### Tags:

access: | public

#### Parameters:

mixed | $value |

[ Top ]

### static method _wrapResult [line 2077]

`static mixed _wrapResult( mixed $value)`

Wrap string values in quotes

#### Tags:

access: | public

#### Parameters:

mixed | $value |

[ Top ]

### destructor __destruct [line 1700]

`void __destruct( )`

#### Tags:

access: | public

[ Top ]

### method calculate [line 2125]

`mixed calculate( [PHPExcel_Cell $pCell = null])`

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

#### Tags:

throws: | Exception
access: | public

#### Parameters:

PHPExcel_Cell | $pCell | Cell to calculate

[ Top ]

### method calculateCellValue [line 2143]

`mixed calculateCellValue( [PHPExcel_Cell $pCell = null], [Boolean $resetLog = true])`

Calculate the value of a cell formula

#### Tags:

throws: | Exception
access: | public

#### Parameters:

PHPExcel_Cell | $pCell | Cell to calculate
Boolean | $resetLog | Flag indicating whether the debug log should be reset or not

[ Top ]

### method calculateFormula [line 2227]

`mixed calculateFormula( string $formula, [ $cellID = null], [PHPExcel_Cell $pCell = null])`

Calculate the value of a formula

#### Tags:

throws: | Exception
access: | public

#### Parameters:

string | $formula | Formula to parse
| $cellID |
PHPExcel_Cell | $pCell |

[ Top ]

### method clearCalculationCache [line 1837]

`void clearCalculationCache( )`

Clear calculation cache

#### Tags:

access: | public

[ Top ]

### method disableCalculationCache [line 1829]

`void disableCalculationCache( )`

Disable calculation cache

#### Tags:

access: | public

[ Top ]

### method enableCalculationCache [line 1821]

`void enableCalculationCache( )`

Enable calculation cache

#### Tags:

access: | public

[ Top ]

### method extractCellRange [line 3611]

`mixed extractCellRange( [string &$pRange = 'A1'], [PHPExcel_Worksheet $pSheet = null], [ $resetLog = true])`

Extract range values

#### Tags:

return: | Array of values in range if range contains more than one element. Otherwise, a single value is returned.
throws: | Exception
access: | public

#### Parameters:

string | &$pRange | String based range representation
PHPExcel_Worksheet | $pSheet | Worksheet
| $resetLog |

[ Top ]

### method extractNamedRange [line 3667]

`mixed extractNamedRange( [string &$pRange = 'A1'], [PHPExcel_Worksheet $pSheet = null], [ $resetLog = true])`

Extract range values

#### Tags:

return: | Array of values in range if range contains more than one element. Otherwise, a single value is returned.
throws: | Exception
access: | public

#### Parameters:

string | &$pRange | String based range representation
PHPExcel_Worksheet | $pSheet | Worksheet
| $resetLog |

[ Top ]

### method getCalculationCacheEnabled [line 1801]

`boolean getCalculationCacheEnabled( )`

Is calculation caching enabled?

#### Tags:

access: | public

[ Top ]

### method getCalculationCacheExpirationTime [line 1847]

`float getCalculationCacheExpirationTime( )`

Get calculation cache expiration time

#### Tags:

access: | public

[ Top ]

### method getLocale [line 1869]

`string getLocale( )`

Get the currently defined locale code

#### Tags:

access: | public

[ Top ]

### method isImplemented [line 3749]

`boolean isImplemented( [string $pFunction = ''])`

Is a specific function implemented?

#### Tags:

access: | public

#### Parameters:

string | $pFunction | Function Name

[ Top ]

### method listAllFunctionNames [line 3787]

`array listAllFunctionNames( )`

Get a list of all Excel function names

#### Tags:

access: | public

[ Top ]

### method listFunctionNames [line 3796]

`array listFunctionNames( )`

Get a list of implemented Excel function names

#### Tags:

access: | public

[ Top ]

### method listFunctions [line 3764]

`array listFunctions( )`

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

#### Tags:

return: | of PHPExcel_Calculation_Function
access: | public

[ Top ]

### method parseFormula [line 2207]

`array parseFormula( string $formula)`

Validate and parse a formula string

#### Tags:

throws: | Exception
access: | public

#### Parameters:

string | $formula | Formula to parse

[ Top ]

### method setCalculationCacheEnabled [line 1812]

`void setCalculationCacheEnabled( [boolean $pValue = true])`

Enable/disable calculation cache

#### Tags:

access: | public

#### Parameters:

boolean | $pValue |

[ Top ]

### method setCalculationCacheExpirationTime [line 1857]

`void setCalculationCacheExpirationTime( [float $pValue = 15])`

Set calculation cache expiration time

#### Tags:

access: | public

#### Parameters:

float | $pValue |

[ Top ]

### method setLocale [line 1879]

`boolean setLocale( [ $locale = 'en_us'])`

Set the locale code

#### Tags:

access: | public

#### Parameters:

| $locale |

[ Top ]

### method _calculateFormulaValue [line 2259]

`mixed _calculateFormulaValue( string $formula, [string $cellID = null], [PHPExcel_Cell $pCell = null])`

Parse a cell formula and calculate its value

#### Tags:

throws: | Exception
access: | public

#### 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

[ Top ]

### method _raiseFormulaError [line 3595]

`void _raiseFormulaError( $errorMessage)`

#### Tags:

access: | protected

#### Parameters:

| $errorMessage |

[ Top ]

### method _translateFormulaToEnglish [line 2031]

`void _translateFormulaToEnglish( $formula)`

#### Tags:

access: | public

#### Parameters:

| $formula |

[ Top ]

### method _translateFormulaToLocale [line 2002]

`void _translateFormulaToLocale( $formula)`

#### Tags:

access: | public

#### Parameters:

| $formula |

[ Top ]

### method __clone [line 1741]

`void __clone( )`

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

#### Tags:

throws: | Exception
access: | public

[ Top ]

### Class Constants

#### CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF

[line 75]

[ Top ]

#### CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'

[line 79]

[ Top ]

#### CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('

[line 73]

[ Top ]

#### CALCULATION_REGEXP_NAMEDRANGE = CALCULATION_REGEXP_NAMEDRANGE

[line 77]

[ Top ]

#### CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?'

[line 67]

Regular Expressions
[ Top ]

#### CALCULATION_REGEXP_OPENBRACE = '\('

[line 71]

[ Top ]

#### CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'

[line 69]

[ Top ]

#### RETURN_ARRAY_AS_ARRAY = 'array'

[line 85]

[ Top ]

#### RETURN_ARRAY_AS_ERROR = 'error'

[line 83]

constants
[ Top ]

#### RETURN_ARRAY_AS_VALUE = 'value'

[line 84]

[ Top ]

Documentation generated on Fri, 12 Oct 2012 00:15:20 +0200 by phpDocumentor 1.4.4