PHPExcel_Writer_Excel5_Parser

category PHPExcel
package PHPExcel_Writer_Excel5
copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)

 Methods

The class constructor

__construct() 

Advance to the next valid token.

_advance() 
access private

pack() row and column into the required 3 or 4 byte format.

_cellToPackedRowcol(string $cell) : array
access private

Parameters

$cell

string

The Excel cell reference to be packed

Returns

arrayArray containing the row and column in packed() format

Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero indexed row and column number.

_cellToRowcol(string $cell) : array

Also returns two (0,1) values to indicate whether the row or column are relative references.

access private

Parameters

$cell

string

The Excel cell reference in A1 format.

Returns

array

It parses a condition.

_condition() : mixed

It assumes the following rule: Cond -> Expr [(">" | "<") Expr]

access private

Returns

mixedThe parsed ptg'd tree on success

Convert a token to the proper ptg value.

_convert(mixed $token) : mixed
access private

Parameters

$token

mixed

The token to convert.

Returns

mixedthe converted token on success

Convert an error code to a ptgErr

_convertError(string $errorCode) : string
access private

Parameters

$errorCode

string

The error code for conversion to its ptg value

Returns

stringThe error code ptgErr

Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.

_convertFunction(string $token, integer $num_args) : string
access private

Parameters

$token

string

The name of the function for convertion to ptg value.

$num_args

integer

The number of arguments the function receives.

Returns

stringThe packed ptg for the function

Convert a number token to ptgInt or ptgNum

_convertNumber(mixed $num) 
access private

Parameters

$num

mixed

an integer or double for conversion to its ptg value

Convert an Excel range such as A1:D4 to a ptgRefV.

_convertRange2d(string $range, int $class) 
access private

Parameters

$range

string

An Excel range in the A1:A2

$class

int

Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to a ptgArea3d.

_convertRange3d(string $token) : mixed
access private

Parameters

$token

string

An Excel range in the Sheet1!A1:A2 format.

Returns

mixedThe packed ptgArea3d token on success.

Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.

_convertRef2d(string $cell) : string
access private

Parameters

$cell

string

An Excel cell reference

Returns

stringThe cell in packed() format with the corresponding ptg

Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a ptgRef3d.

_convertRef3d(string $cell) : mixed
access private

Parameters

$cell

string

An Excel cell reference

Returns

mixedThe packed ptgRef3d token on success.

Convert a string token to ptgStr

_convertString(string $string) : mixed
access private

Parameters

$string

string

A string for conversion to its ptg value.

Returns

mixedthe converted token on success

Creates a tree.

_createTree(mixed $value, mixed $left, mixed $right) : array

In fact an array which may have one or two arrays (sub-trees) as elements.

access private

Parameters

$value

mixed

The value of this node.

$left

mixed

The left array (sub-tree) or a final node.

$right

mixed

The right array (sub-tree) or a final node.

Returns

arrayA tree

It parses a expression.

_expression() : mixed

It assumes the following rule: Expr -> Term [("+" | "-") Term] -> "string" -> "-" Term : Negative value -> "+" Term : Positive value -> Error code

access private

Returns

mixedThe parsed ptg'd tree on success

It parses a factor.

_fact() : mixed

It assumes the following rule: Fact -> ( Expr ) | CellRef | CellRange | Number | Function

access private

Returns

mixedThe parsed ptg'd tree on success

It parses a function call.

_func() : mixed

It assumes the following rule: Func -> ( Expr [,Expr]* )

access private

Returns

mixedThe parsed ptg'd tree on success

Look up the REF index that corresponds to an external sheet name (or range).

_getRefIndex(string $ext_ref) : mixed

If it doesn't exist yet add it to the workbook's references array. It assumes all sheet names given must exist.

access private

Parameters

$ext_ref

string

The name of the external reference

Returns

mixedThe reference index in packed() format on success

Look up the index that corresponds to an external sheet name.

_getSheetIndex(string $sheet_name) : integer

The hash of sheet names is updated by the addworksheet() method of the PHPExcel_Writer_Excel5_Workbook class.

access private

Parameters

$sheet_name

string

Sheet name

Returns

integerThe sheet index, -1 if the sheet was not found

Initialize the ptg and function hashes.

_initializeHashes() 
access private

Checks if it's a valid token.

_match(mixed $token) : mixed
access private

Parameters

$token

mixed

The token to check.

Returns

mixedThe checked token or false on failure

Convert the sheet name part of an external reference, for example "Sheet1" or "Sheet1:Sheet2", to a packed structure.

_packExtRef(string $ext_ref) : string
access private

Parameters

$ext_ref

string

The name of the external reference

Returns

stringThe reference index in packed() format

This function just introduces a ptgParen element in the tree, so that Excel doesn't get confused when working with a parenthesized formula afterwards.

_parenthesizedExpression() : array
access private
see \_fact()

Returns

arrayThe parsed ptg'd tree

pack() row range into the required 3 or 4 byte format.

_rangeToPackedRange(string $range) : array

Just using maximum col/rows, which is probably not the correct solution

access private

Parameters

$range

string

The Excel range to be packed

Returns

arrayArray containing (row1,col1,row2,col2) in packed() format

It parses a term.

_term() : mixed

It assumes the following rule: Term -> Fact [("*" | "/") Fact]

access private

Returns

mixedThe parsed ptg'd tree on success

The parsing method.

parse(string $formula) : mixed

It parses a formula.

access public

Parameters

$formula

string

The formula to parse, without the initial equal sign (=).

Returns

mixedtrue on success

This method is used to update the array of sheet names.

setExtSheet(string $name, integer $index) 

It is called by the addWorksheet() method of the PHPExcel_Writer_Excel5_Workbook class.

access public
see \PHPExcel_Writer_Excel5_Workbook::addWorksheet()

Parameters

$name

string

The name of the worksheet being added

$index

integer

The index of the worksheet being added

Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack).

toReversePolish(array $tree) : string

The following tree:

+ / \ 2 3

produces: "23+"

The following tree:

+ / \ 3 * / \ 6 A1

produces: "36A1*+"

In fact all operands, functions, references, etc... are written as ptg's

access public

Parameters

$tree

array

The optional tree to convert.

Returns

stringThe tree in reverse polish notation

 Properties

 

$_current_char : integer
 

$_current_token : string
 

$_ext_sheets : array
 

$_formula : string
 

$_lookahead : string
 

$_parse_tree : string
 

$_references : array

 Constants

 

REGEX_SHEET_TITLE_QUOTED

REGEX_SHEET_TITLE_QUOTED 
 

REGEX_SHEET_TITLE_UNQUOTED

REGEX_SHEET_TITLE_UNQUOTED