Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
|
Public Member Functions | |
__construct (?Spreadsheet $spreadsheet=null) | |
__clone () | |
__clone implementation. | |
_calculateFormulaValue (string $formula, ?string $cellID=null, ?Cell $cell=null, bool $ignoreQuotePrefix=false) | |
Parse a cell formula and calculate its value. | |
calculate (?Cell $cell=null) | |
Calculate cell value (using formula from a cell ID) Retained for backward compatibility. | |
calculateCellValue (?Cell $cell=null, bool $resetLog=true) | |
Calculate the value of a cell formula. | |
calculateFormula (string $formula, ?string $cellID=null, ?Cell $cell=null) | |
Calculate the value of a formula. | |
clearCalculationCache () | |
Clear calculation cache. | |
clearCalculationCacheForWorksheet (string $worksheetName) | |
Clear calculation cache for a specified worksheet. | |
disableBranchPruning () | |
disableCalculationCache () | |
Disable calculation cache. | |
enableBranchPruning () | |
enableCalculationCache () | |
Enable calculation cache. | |
extractCellRange (string &$range='A1', ?Worksheet $worksheet=null, bool $resetLog=true) | |
Extract range values. | |
extractNamedRange (string &$range='A1', ?Worksheet $worksheet=null, bool $resetLog=true) | |
Extract range values. | |
flushInstance () | |
Flush the calculation cache for any existing instance of this class but only if a Calculation instance exists. | |
getCalculationCacheEnabled () | |
Is calculation caching enabled? | |
getDebugLog () | |
Get the Logger for this calculation engine instance. | |
getImplementedFunctionNames () | |
Get a list of implemented Excel function names. | |
getInstanceArrayReturnType () | |
Return the Array Return Type (Array or Value of first element in the array). | |
getLocale () | |
Get the currently defined locale code. | |
getSuppressFormulaErrors () | |
getValueFromCache (string $cellReference, mixed &$cellValue) | |
isImplemented (string $function) | |
Is a specific function implemented? | |
parseFormula (string $formula) | |
Validate and parse a formula string. | |
renameCalculationCacheForWorksheet (string $fromWorksheetName, string $toWorksheetName) | |
Rename calculation cache for a specified worksheet. | |
saveValueToCache (string $cellReference, mixed $cellValue) | |
setBranchPruningEnabled (mixed $enabled) | |
Enable/disable calculation cache. | |
setCalculationCacheEnabled (bool $calculationCacheEnabled) | |
Enable/disable calculation cache. | |
setInstanceArrayReturnType (string $returnType) | |
Set the Instance Array Return Type (Array or Value of first element in the array). | |
setLocale (string $locale) | |
Set the locale code. | |
setSuppressFormulaErrors (bool $suppressFormulaErrors) | |
translateFormulaToEnglish (string $formula) | |
translateFormulaToLocale (string $formula) | |
Static Public Member Functions | |
static | boolToString (mixed $operand1) |
static | checkMatrixOperands (mixed &$operand1, mixed &$operand2, int $resize=1) |
Ensure that paired matrix operands are both matrices and of the same size. | |
static | getArrayReturnType () |
Return the Array Return Type (Array or Value of first element in the array). | |
static | getExcelConstants (string $key) |
static | getFALSE () |
Return the locale-specific translation of FALSE. | |
static | getFunctions () |
Get a list of all implemented functions as an array of function objects. | |
static | getInstance (?Spreadsheet $spreadsheet=null) |
Get an instance of this class. | |
static static | getLocaleBoolean (string $index) |
static | getMatrixDimensions (array &$matrix) |
Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0. | |
static | getTRUE () |
Return the locale-specific translation of TRUE. | |
static array< string, array $excelConstants=[ 'TRUE'=> static | keyInExcelConstants (string $key) |
static | localeFunc (string $function) |
static | setArrayReturnType (string $returnType) |
Set the Array Return Type (Array or Value of first element in the array). | |
static | translateSeparator (string $fromSeparator, string $toSeparator, string $formula, int &$inBracesLevel, string $openBrace=self::FORMULA_OPEN_FUNCTION_BRACE, string $closeBrace=self::FORMULA_CLOSE_FUNCTION_BRACE) |
static | unwrapResult (mixed $value) |
Remove quotes used as a wrapper to identify string values. | |
static | wrapResult (mixed $value) |
Wrap string values in quotes. | |
Public Attributes | |
int | $cyclicFormulaCount = 1 |
Number of iterations for cyclic formulae. | |
return | $falseTrueArray |
string | $formulaError = null |
Error message for any error that was raised/thrown by the calculation engine. | |
catch(Exception $e) | $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [] |
const | CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*::+<>=:`-]*)|(::'(?:[^::']|'[^!])+?::')|(::"(?:[^::"]|"[^!])+?::"))!)?::$?::b([a-z]{1,3})::$?(::d{1,7})(?![::w.])' |
const | CALCULATION_REGEXP_CELLREF_RELATIVE = '((([^\s\(,!&%^\/\*::+<>=:`-]*)|(::'(?:[^::']|'[^!])+?::')|(::"(?:[^::"]|"[^!])+?::"))!)?(::$?::b[a-z]{1,3})(::$?::d{1,7})(?![::w.])' |
const | CALCULATION_REGEXP_CELLREF_SPILL = '/' . self::CALCULATION_REGEXP_CELLREF . '#/i' |
const | CALCULATION_REGEXP_COLUMN_RANGE = '(((([^\s\(,!&%^\/\*::+<>=:`-]*)|(::'(?:[^::']|'[^!])+?::')|(::".(?:[^::"]|"[^!])?::"))!)?(::$?[a-z]{1,3})):(?![.*])' |
const | CALCULATION_REGEXP_COLUMNRANGE_RELATIVE = '(\$?[a-z]{1,3}):(\$?[a-z]{1,3})' |
const | CALCULATION_REGEXP_DEFINEDNAME = '((([^\s,!&%^\/\*::+<>=-]*)|(::'(?:[^::']|'[^!])+?::')|(::"(?:[^::"]|"[^!])+?::"))!)?([_::p{L}][_::p{L}::p{N}::.]*)' |
const | CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!::?]?' |
const | CALCULATION_REGEXP_FUNCTION = '@?(?:_xlfn\.)?(?:_xlws\.)?([\p{L}][\p{L}\p{N}\.]*)[::s]*::(' |
file home runner work phpdoc phpdoc moodle lib phpspreadsheet phpspreadsheet src PhpSpreadsheet Calculation Calculation php const | CALCULATION_REGEXP_NUMBER = '[-+]?\d*::.?::d+(e[-+]?::d+)?' |
Constants. | |
const | CALCULATION_REGEXP_OPENBRACE = '\(' |
const | CALCULATION_REGEXP_ROW_RANGE = '(((([^\s\(,!&%^\/\*::+<>=:`-]*)|(::'(?:[^::']|'[^!])+?::')|(::"(?:[^::"]|"[^!])+?::"))!)?(::$?[1-9][0-9]{0,6})):(?![.*])' |
const | CALCULATION_REGEXP_ROWRANGE_RELATIVE = '(\$?\d{1,7}):(\$?\d{1,7})' |
const | CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"' |
const | CALCULATION_REGEXP_STRIP_XLFN_XLWS = '/(_xlfn[.])?(_xlws[.])?(?=[\p{L}][\p{L}\p{N}\.]*[::s]*[(])/' |
const | CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)' |
const | FORMULA_CLOSE_FUNCTION_BRACE = ')' |
const | FORMULA_CLOSE_MATRIX_BRACE = '}' |
const | FORMULA_OPEN_FUNCTION_BRACE = '(' |
const | FORMULA_OPEN_MATRIX_BRACE = '{' |
const | FORMULA_STRING_QUOTE = '"' |
const | RETURN_ARRAY_AS_ARRAY = 'array' |
const | RETURN_ARRAY_AS_ERROR = 'error' |
constants | |
const | RETURN_ARRAY_AS_VALUE = 'value' |
Protected Member Functions | |
raiseFormulaError (string $errorMessage, int $code=0, ?Throwable $exception=null) | |
Trigger an error, but nicely, if need be. | |
|
final |
__clone implementation.
Cloning should not be allowed in a Singleton!
PhpOffice\PhpSpreadsheet\Calculation\Calculation::_calculateFormulaValue | ( | string | $formula, |
?string | $cellID = null, | ||
?Cell | $cell = null, | ||
bool | $ignoreQuotePrefix = false ) |
Parse a cell formula and calculate its value.
string | $formula | The formula to parse and calculate |
?string | $cellID | The ID (e.g. A3) of the cell that we are calculating |
?Cell | $cell | Cell to calculate |
bool | $ignoreQuotePrefix | If set to true, evaluate the formyla even if the referenced cell is quote prefixed |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::calculate | ( | ?Cell | $cell = null | ) |
Calculate cell value (using formula from a cell ID) Retained for backward compatibility.
?Cell | $cell | Cell to calculate |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::calculateCellValue | ( | ?Cell | $cell = null, |
bool | $resetLog = true ) |
Calculate the value of a cell formula.
?Cell | $cell | Cell to calculate |
bool | $resetLog | Flag indicating whether the debug log should be reset or not |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::calculateFormula | ( | string | $formula, |
?string | $cellID = null, | ||
?Cell | $cell = null ) |
Calculate the value of a formula.
string | $formula | Formula to parse |
?string | $cellID | Address of the cell to calculate |
?Cell | $cell | Cell to calculate |
|
static |
Ensure that paired matrix operands are both matrices and of the same size.
mixed | $operand1 | First matrix operand |
mixed | $operand2 | Second matrix operand |
int | $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 |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::extractCellRange | ( | string & | $range = 'A1', |
?Worksheet | $worksheet = null, | ||
bool | $resetLog = true ) |
Extract range values.
string | $range | String based range representation |
?Worksheet | $worksheet | Worksheet |
bool | $resetLog | Flag indicating whether calculation log should be reset or not |
array | Array of values in range if range contains more than one element. Otherwise, a single value is returned. |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::extractNamedRange | ( | string & | $range = 'A1', |
?Worksheet | $worksheet = null, | ||
bool | $resetLog = true ) |
Extract range values.
string | $range | String based range representation |
null | Worksheet | $worksheet | Worksheet |
bool | $resetLog | Flag indicating whether calculation log should be reset or not |
array|string | Array of values in range if range contains more than one element. Otherwise, a single value is returned. |
|
static |
Return the Array Return Type (Array or Value of first element in the array).
string#$returnType | Array return type |
|
static |
Return the locale-specific translation of FALSE.
string | locale-specific translation of FALSE |
|
static |
Get an instance of this class.
?Spreadsheet | $spreadsheet | Injected spreadsheet for working with a PhpSpreadsheet Spreadsheet object, or NULL to create a standalone calculation engine |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstanceArrayReturnType | ( | ) |
Return the Array Return Type (Array or Value of first element in the array).
string#$returnType | Array return type for instance if non-null, otherwise static property |
|
static |
Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0.
array | $matrix | matrix operand |
int[] | An array comprising the number of rows, and number of columns |
|
static |
Return the locale-specific translation of TRUE.
string | locale-specific translation of TRUE |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::isImplemented | ( | string | $function | ) |
Is a specific function implemented?
string | $function | Function Name |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::parseFormula | ( | string | $formula | ) |
Validate and parse a formula string.
string | $formula | Formula to parse |
|
protected |
Trigger an error, but nicely, if need be.
false |
|
static |
Set the Array Return Type (Array or Value of first element in the array).
string | $returnType | Array return type |
bool | Success or failure |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::setInstanceArrayReturnType | ( | string | $returnType | ) |
Set the Instance Array Return Type (Array or Value of first element in the array).
string | $returnType | Array return type |
bool | Success or failure |
PhpOffice\PhpSpreadsheet\Calculation\Calculation::setLocale | ( | string | $locale | ) |
Set the locale code.
string | $locale | The locale to use for formula translation, eg: 'en_us' |
file home runner work phpdoc phpdoc moodle lib phpspreadsheet phpspreadsheet src PhpSpreadsheet Calculation Calculation php const PhpOffice\PhpSpreadsheet\Calculation\Calculation::CALCULATION_REGEXP_NUMBER = '[-+]?\d*::.?::d+(e[-+]?::d+)?' |
Constants.
Regular Expressions