Spreadsheet_Excel_Writer
[ class tree: Spreadsheet_Excel_Writer ] [ index: Spreadsheet_Excel_Writer ] [ all elements ]

Class: Spreadsheet_Excel_Writer_Parser

Source Location: /main/inc/lib/pear/Spreadsheet_Excel_Writer/Writer/Parser.php

Class Overview

PEAR
   |
   --Spreadsheet_Excel_Writer_Parser

Class for parsing Excel formulas


Author(s):

Version:

  • Release: 1.4.11

Copyright:

  • 1997-2006 The PHP Group

Variables

Methods


Inherited Variables

Inherited Methods

Class: PEAR

PEAR::PEAR()
Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.
PEAR::delExpect()
This method deletes all occurences of the specified element from the expected error codes stack.
PEAR::expectError()
This method is used to tell which errors you expect to get.
PEAR::getStaticProperty()
If you have a class that's mostly/entirely static, and you need static
PEAR::isError()
Tell whether a value is a PEAR error.
PEAR::loadExtension()
OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.
PEAR::popErrorHandling()
Pop the last error handler used
PEAR::popExpect()
This method pops one element off the expected error codes stack.
PEAR::pushErrorHandling()
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.
PEAR::raiseError()
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.
PEAR::registerShutdownFunc()
Use this function to register a shutdown method for static classes.
PEAR::setErrorHandling()
Sets how errors generated by this object should be handled.
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::throwError()
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::_checkDelExpect()
This method checks unsets an error code if available
PEAR::_PEAR()
Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

Class Details

[line 106]
Class for parsing Excel formulas



Tags:

author:  Xavier Noguer <xnoguer@rezebra.com>
version:  Release: 1.4.11
copyright:  1997-2006 The PHP Group


[ Top ]


Class Variables

$_BIFF_version =

[line 160]

The BIFF version for the workbook


Type:   integer


[ Top ]

$_byte_order =

[line 142]

The byte order. 1 => big endian, 0 => little endian.


Type:   integer


[ Top ]

$_current_char =

[line 112]

The index of the character we are currently looking at


Type:   integer


[ Top ]

$_current_token =

[line 118]

The token we are working on.


Type:   string


[ Top ]

$_ext_sheets =

[line 148]

Array of external sheets


Type:   array


[ Top ]

$_formula =

[line 124]

The formula to parse


Type:   string


[ Top ]

$_lookahead =

[line 130]

The character ahead of the current char


Type:   string


[ Top ]

$_parse_tree =

[line 136]

The parse tree to be generated


Type:   string


[ Top ]

$_references =

[line 154]

Array of sheet references in the form of REF structures


Type:   array


[ Top ]



Class Methods


constructor Spreadsheet_Excel_Writer_Parser [line 168]

Spreadsheet_Excel_Writer_Parser Spreadsheet_Excel_Writer_Parser( integer $byte_order, $biff_version)

The class constructor



Parameters:

integer   $byte_order   The byte order (Little endian or Big endian) of the architecture
   $biff_version  

[ Top ]

method parse [line 1282]

mixed parse( string $formula)

The parsing method. It parses a formula.



Tags:

return:  true on success, PEAR_Error on failure
access:  public


Parameters:

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

[ Top ]

method setExtSheet [line 980]

void setExtSheet( string $name, integer $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.



Tags:



Parameters:

string   $name   The name of the worksheet being added
integer   $index   The index of the worksheet being added

[ Top ]

method toReversePolish [line 1629]

string toReversePolish( [array $tree = array()])

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

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




Tags:

return:  The tree in reverse polish notation
access:  public


Parameters:

array   $tree   The optional tree to convert.

[ Top ]

method _advance [line 1104]

void _advance( )

Advance to the next valid token.



Tags:

access:  private


[ Top ]

method _cellToPackedRowcol [line 992]

array _cellToPackedRowcol( string $cell)

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



Tags:

return:  Array containing the row and column in packed() format
access:  private


Parameters:

string   $cell   The Excel cell reference to be packed

[ Top ]

method _cellToRowcol [line 1074]

array _cellToRowcol( string $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.



Tags:

access:  private


Parameters:

string   $cell   The Excel cell reference in A1 format.

[ Top ]

method _condition [line 1302]

mixed _condition( )

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



Tags:

return:  The parsed ptg'd tree on success, PEAR_Error on failure
access:  private


[ Top ]

method _convert [line 539]

mixed _convert( mixed $token)

Convert a token to the proper ptg value.



Tags:

return:  the converted token on success. PEAR_Error if the token is not recognized
access:  private


Parameters:

mixed   $token   The token to convert.

[ Top ]

method _convertFunction [line 645]

string _convertFunction( string $token, integer $num_args)

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



Tags:

return:  The packed ptg for the function
access:  private


Parameters:

string   $token   The name of the function for convertion to ptg value.
integer   $num_args   The number of arguments the function receives.

[ Top ]

method _convertNumber [line 599]

void _convertNumber( mixed $num)

Convert a number token to ptgInt or ptgNum



Tags:

access:  private


Parameters:

mixed   $num   an integer or double for conversion to its ptg value

[ Top ]

method _convertRange2d [line 666]

void _convertRange2d( string $range)

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



Tags:

access:  private


Parameters:

string   $range   An Excel range in the A1:A2 or A1..A2 format.

[ Top ]

method _convertRange3d [line 715]

mixed _convertRange3d( string $token)

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



Tags:

return:  The packed ptgArea3d token on success, PEAR_Error on failure.
access:  private


Parameters:

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

[ Top ]

method _convertRef2d [line 779]

string _convertRef2d( string $cell)

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



Tags:

return:  The cell in packed() format with the corresponding ptg
access:  private


Parameters:

string   $cell   An Excel cell reference

[ Top ]

method _convertRef3d [line 812]

mixed _convertRef3d( string $cell)

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



Tags:

return:  The packed ptgRef3d token on success, PEAR_Error on failure.
access:  private


Parameters:

string   $cell   An Excel cell reference

[ Top ]

method _convertString [line 620]

mixed _convertString( string $string)

Convert a string token to ptgStr



Tags:

return:  the converted token on success. PEAR_Error if the string is longer than 255 characters.
access:  private


Parameters:

string   $string   A string for conversion to its ptg value.

[ Top ]

method _createTree [line 1597]

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

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



Tags:

return:  A tree
access:  private


Parameters:

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.

[ Top ]

method _expression [line 1363]

mixed _expression( )

It parses a expression. It assumes the following rule:

Expr -> Term [("+" | "-") Term] -> "string" -> "-" Term




Tags:

return:  The parsed ptg'd tree on success, PEAR_Error on failure
access:  private


[ Top ]

method _fact [line 1463]

mixed _fact( )

It parses a factor. It assumes the following rule:

Fact -> ( Expr ) | CellRef | CellRange | Number | Function




Tags:

return:  The parsed ptg'd tree on success, PEAR_Error on failure
access:  private


[ Top ]

method _func [line 1541]

mixed _func( )

It parses a function call. It assumes the following rule: Func -> ( Expr [,Expr]* )



Tags:

return:  The parsed ptg'd tree on success, PEAR_Error on failure
access:  private


[ Top ]

method _getRefIndex [line 903]

mixed _getRefIndex( string $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.



Tags:

return:  The reference index in packed() format on success, PEAR_Error on failure
access:  private


Parameters:

string   $ext_ref   The name of the external reference

[ Top ]

method _getSheetIndex [line 961]

integer _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.



Tags:

return:  The sheet index, -1 if the sheet was not found
access:  private


Parameters:

   $sheet_name  

[ Top ]

method _initializeHashes [line 187]

void _initializeHashes( )

Initialize the ptg and function hashes.



Tags:

access:  private


[ Top ]

method _match [line 1154]

mixed _match( mixed $token)

Checks if it's a valid token.



Tags:

return:  The checked token or false on failure
access:  private


Parameters:

mixed   $token   The token to check.

[ Top ]

method _packExtRef [line 857]

string _packExtRef( string $ext_ref)

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



Tags:

return:  The reference index in packed() format
access:  private


Parameters:

string   $ext_ref   The name of the external reference

[ Top ]

method _parenthesizedExpression [line 1411]

array _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.



Tags:

return:  The parsed ptg'd tree
see:  Spreadsheet_Excel_Writer_Parser::_fact()
access:  private


[ Top ]

method _rangeToPackedRange [line 1027]

array _rangeToPackedRange( string $range)

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

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




Tags:

return:  Array containing (row1,col1,row2,col2) in packed() format
access:  private


Parameters:

string   $range   The Excel range to be packed

[ Top ]

method _term [line 1424]

mixed _term( )

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



Tags:

return:  The parsed ptg'd tree on success, PEAR_Error on failure
access:  private


[ Top ]


Documentation generated on Thu, 12 Jun 2008 14:10:23 -0500 by phpDocumentor 1.4.1