ILIAS
Release_3_10_x_branch Revision 61812
|
Public Member Functions | |
Spreadsheet_Excel_Writer_Parser ($byte_order, $biff_version) | |
The class constructor. | |
_initializeHashes () | |
Initialize the ptg and function hashes. | |
_convert ($token) | |
Convert a token to the proper ptg value. | |
_convertNumber ($num) | |
Convert a number token to ptgInt or ptgNum. | |
_convertString ($string) | |
Convert a string token to ptgStr. | |
_convertFunction ($token, $num_args) | |
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes. | |
_convertRange2d ($range) | |
Convert an Excel range such as A1:D4 to a ptgRefV. | |
_convertRange3d ($token) | |
Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to a ptgArea3d. | |
_convertRef2d ($cell) | |
Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV. | |
_convertRef3d ($cell) | |
Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a ptgRef3d. | |
_packExtRef ($ext_ref) | |
Convert the sheet name part of an external reference, for example "Sheet1" or "Sheet1:Sheet2", to a packed structure. | |
_getRefIndex ($ext_ref) | |
Look up the REF index that corresponds to an external sheet name (or range). | |
_getSheetIndex ($sheet_name) | |
Look up the index that corresponds to an external sheet name. | |
setExtSheet ($name, $index) | |
This method is used to update the array of sheet names. | |
_cellToPackedRowcol ($cell) | |
pack() row and column into the required 3 or 4 byte format. | |
_rangeToPackedRange ($range) | |
pack() row range into the required 3 or 4 byte format. | |
_cellToRowcol ($cell) | |
Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero indexed row and column number. | |
_advance () | |
Advance to the next valid token. | |
_match ($token) | |
Checks if it's a valid token. | |
parse ($formula) | |
The parsing method. | |
_condition () | |
It parses a condition. | |
_expression () | |
It parses a expression. | |
_parenthesizedExpression () | |
This function just introduces a ptgParen element in the tree, so that Excel doesn't get confused when working with a parenthesized formula afterwards. | |
_term () | |
It parses a term. | |
_fact () | |
It parses a factor. | |
_func () | |
It parses a function call. | |
_createTree ($value, $left, $right) | |
Creates a tree. | |
toReversePolish ($tree=array()) | |
Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack). |
Data Fields | |
$_current_char | |
$_current_token | |
$_formula | |
$_lookahead | |
$_parse_tree | |
$_byte_order | |
$_ext_sheets | |
$_references | |
$_BIFF_version |
Definition at line 106 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::_advance | ( | ) |
Advance to the next valid token.
private
Definition at line 1144 of file Parser.php.
References $_current_char, and _match().
Referenced by _condition(), _expression(), _fact(), _func(), _term(), and parse().
Spreadsheet_Excel_Writer_Parser::_cellToPackedRowcol | ( | $cell | ) |
pack() row and column into the required 3 or 4 byte format.
private
string | $cell | The Excel cell reference to be packed |
Definition at line 1030 of file Parser.php.
References _cellToRowcol().
Referenced by _convertRange2d(), _convertRange3d(), _convertRef2d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_cellToRowcol | ( | $cell | ) |
Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero indexed row and column number.
Also returns two (0,1) values to indicate whether the row or column are relative references.
private
string | $cell | The Excel cell reference in A1 format. |
Definition at line 1114 of file Parser.php.
Referenced by _cellToPackedRowcol().
Spreadsheet_Excel_Writer_Parser::_condition | ( | ) |
It parses a condition.
It assumes the following rule: Cond -> Expr [(">" | "<") Expr]
private
Definition at line 1344 of file Parser.php.
References $result, _advance(), _createTree(), _expression(), SPREADSHEET_EXCEL_WRITER_EQ, SPREADSHEET_EXCEL_WRITER_GE, SPREADSHEET_EXCEL_WRITER_GT, SPREADSHEET_EXCEL_WRITER_LE, SPREADSHEET_EXCEL_WRITER_LT, and SPREADSHEET_EXCEL_WRITER_NE.
Referenced by _func(), and parse().
Spreadsheet_Excel_Writer_Parser::_convert | ( | $token | ) |
Convert a token to the proper ptg value.
private
mixed | $token | The token to convert. |
Definition at line 539 of file Parser.php.
References _convertNumber(), _convertRange2d(), _convertRange3d(), _convertRef2d(), _convertRef3d(), and _convertString().
Referenced by toReversePolish().
Spreadsheet_Excel_Writer_Parser::_convertFunction | ( | $token, | |
$num_args | |||
) |
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.
private
string | $token | The name of the function for convertion to ptg value. |
integer | $num_args | The number of arguments the function receives. |
Definition at line 656 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::_convertNumber | ( | $num | ) |
Convert a number token to ptgInt or ptgNum.
private
mixed | $num | an integer or double for conversion to its ptg value |
Definition at line 608 of file Parser.php.
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRange2d | ( | $range | ) |
Convert an Excel range such as A1:D4 to a ptgRefV.
private
string | $range | An Excel range in the A1:A2 or A1..A2 format. |
Definition at line 677 of file Parser.php.
References _cellToPackedRowcol().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRange3d | ( | $token | ) |
Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to a ptgArea3d.
private
string | $token | An Excel range in the Sheet1!A1:A2 format. |
Definition at line 731 of file Parser.php.
References _cellToPackedRowcol(), _getRefIndex(), _packExtRef(), and _rangeToPackedRange().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRef2d | ( | $cell | ) |
Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.
private
string | $cell | An Excel cell reference |
Definition at line 801 of file Parser.php.
References _cellToPackedRowcol().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertRef3d | ( | $cell | ) |
Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a ptgRef3d.
private
string | $cell | An Excel cell reference |
Definition at line 837 of file Parser.php.
References _cellToPackedRowcol(), _getRefIndex(), and _packExtRef().
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_convertString | ( | $string | ) |
Convert a string token to ptgStr.
private
string | $string | A string for conversion to its ptg value. |
Definition at line 631 of file Parser.php.
Referenced by _convert().
Spreadsheet_Excel_Writer_Parser::_createTree | ( | $value, | |
$left, | |||
$right | |||
) |
Creates a tree.
In fact an array which may have one or two arrays (sub-trees) as elements.
private
mixed | $value | The value of this node. |
mixed | $left | The left array (sub-tree) or a final node. |
mixed | $right | The right array (sub-tree) or a final node. |
Definition at line 1658 of file Parser.php.
Referenced by _condition(), _expression(), _fact(), _func(), _parenthesizedExpression(), and _term().
Spreadsheet_Excel_Writer_Parser::_expression | ( | ) |
It parses a expression.
It assumes the following rule: Expr -> Term [("+" | "-") Term] -> "string" -> "-" Term
private
Definition at line 1416 of file Parser.php.
References $result, _advance(), _createTree(), _term(), SPREADSHEET_EXCEL_WRITER_ADD, and SPREADSHEET_EXCEL_WRITER_SUB.
Referenced by _condition(), and _parenthesizedExpression().
Spreadsheet_Excel_Writer_Parser::_fact | ( | ) |
It parses a factor.
It assumes the following rule: Fact -> ( Expr ) | CellRef | CellRange | Number | Function
private
Definition at line 1523 of file Parser.php.
References $_current_token, $result, _advance(), _createTree(), _func(), _parenthesizedExpression(), SPREADSHEET_EXCEL_WRITER_CLOSE, and SPREADSHEET_EXCEL_WRITER_OPEN.
Referenced by _term().
Spreadsheet_Excel_Writer_Parser::_func | ( | ) |
It parses a function call.
It assumes the following rule: Func -> ( Expr [,Expr]* )
private
Definition at line 1602 of file Parser.php.
References $_current_token, $result, _advance(), _condition(), _createTree(), SPREADSHEET_EXCEL_WRITER_COMA, and SPREADSHEET_EXCEL_WRITER_SEMICOLON.
Referenced by _fact().
Spreadsheet_Excel_Writer_Parser::_getRefIndex | ( | $ext_ref | ) |
Look up the REF index that corresponds to an external sheet name (or range).
If it doesn't exist yet add it to the workbook's references array. It assumes all sheet names given must exist.
private
string | $ext_ref | The name of the external reference |
Definition at line 935 of file Parser.php.
References _getSheetIndex().
Referenced by _convertRange3d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_getSheetIndex | ( | $sheet_name | ) |
Look up the index that corresponds to an external sheet name.
The hash of sheet names is updated by the addworksheet() method of the Spreadsheet_Excel_Writer_Workbook class.
private
Definition at line 998 of file Parser.php.
Referenced by _getRefIndex(), and _packExtRef().
Spreadsheet_Excel_Writer_Parser::_initializeHashes | ( | ) |
Initialize the ptg and function hashes.
private
Definition at line 187 of file Parser.php.
Referenced by Spreadsheet_Excel_Writer_Parser().
Spreadsheet_Excel_Writer_Parser::_match | ( | $token | ) |
Checks if it's a valid token.
private
mixed | $token | The token to check. |
Definition at line 1195 of file Parser.php.
References SPREADSHEET_EXCEL_WRITER_ADD, SPREADSHEET_EXCEL_WRITER_CLOSE, SPREADSHEET_EXCEL_WRITER_COMA, SPREADSHEET_EXCEL_WRITER_DIV, SPREADSHEET_EXCEL_WRITER_EQ, SPREADSHEET_EXCEL_WRITER_GE, SPREADSHEET_EXCEL_WRITER_GT, SPREADSHEET_EXCEL_WRITER_LE, SPREADSHEET_EXCEL_WRITER_LT, SPREADSHEET_EXCEL_WRITER_MUL, SPREADSHEET_EXCEL_WRITER_NE, SPREADSHEET_EXCEL_WRITER_OPEN, SPREADSHEET_EXCEL_WRITER_SEMICOLON, and SPREADSHEET_EXCEL_WRITER_SUB.
Referenced by _advance().
Spreadsheet_Excel_Writer_Parser::_packExtRef | ( | $ext_ref | ) |
Convert the sheet name part of an external reference, for example "Sheet1" or "Sheet1:Sheet2", to a packed structure.
private
string | $ext_ref | The name of the external reference |
Definition at line 886 of file Parser.php.
References _getSheetIndex().
Referenced by _convertRange3d(), and _convertRef3d().
Spreadsheet_Excel_Writer_Parser::_parenthesizedExpression | ( | ) |
This function just introduces a ptgParen element in the tree, so that Excel doesn't get confused when working with a parenthesized formula afterwards.
private
Definition at line 1468 of file Parser.php.
References $result, _createTree(), and _expression().
Referenced by _fact().
Spreadsheet_Excel_Writer_Parser::_rangeToPackedRange | ( | $range | ) |
pack() row range into the required 3 or 4 byte format.
Just using maximum col/rows, which is probably not the correct solution
private
string | $range | The Excel range to be packed |
Definition at line 1066 of file Parser.php.
Referenced by _convertRange3d().
Spreadsheet_Excel_Writer_Parser::_term | ( | ) |
It parses a term.
It assumes the following rule: Term -> Fact [("*" | "/") Fact]
private
Definition at line 1481 of file Parser.php.
References $result, _advance(), _createTree(), _fact(), SPREADSHEET_EXCEL_WRITER_DIV, and SPREADSHEET_EXCEL_WRITER_MUL.
Referenced by _expression().
Spreadsheet_Excel_Writer_Parser::parse | ( | $formula | ) |
The parsing method.
It parses a formula.
public
string | $formula | The formula to parse, without the initial equal sign (=). |
Definition at line 1324 of file Parser.php.
References $_parse_tree, _advance(), and _condition().
Spreadsheet_Excel_Writer_Parser::setExtSheet | ( | $name, | |
$index | |||
) |
This method is used to update the array of sheet names.
It is called by the addWorksheet() method of the Spreadsheet_Excel_Writer_Workbook class.
public
string | $name | The name of the worksheet being added |
integer | $index | The index of the worksheet being added |
Definition at line 1018 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::Spreadsheet_Excel_Writer_Parser | ( | $byte_order, | |
$biff_version | |||
) |
The class constructor.
integer | $byte_order | The byte order (Little endian or Big endian) of the architecture (optional). 1 => big endian, 0 (default) little endian. |
Definition at line 168 of file Parser.php.
References _initializeHashes().
Spreadsheet_Excel_Writer_Parser::toReversePolish | ( | $tree = array() | ) |
Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack).
The following tree:
produces: "23+"
The following tree:
produces: "36A1*+"
In fact all operands, functions, references, etc... are written as ptg's
public
array | $tree | The optional tree to convert. |
Definition at line 1690 of file Parser.php.
References $_parse_tree, and _convert().
Spreadsheet_Excel_Writer_Parser::$_BIFF_version |
Definition at line 160 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_byte_order |
Definition at line 142 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_current_char |
Definition at line 112 of file Parser.php.
Referenced by _advance().
Spreadsheet_Excel_Writer_Parser::$_current_token |
Definition at line 118 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_ext_sheets |
Definition at line 148 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_formula |
Definition at line 124 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_lookahead |
Definition at line 130 of file Parser.php.
Spreadsheet_Excel_Writer_Parser::$_parse_tree |
Definition at line 136 of file Parser.php.
Referenced by parse(), and toReversePolish().
Spreadsheet_Excel_Writer_Parser::$_references |
Definition at line 154 of file Parser.php.