Documentation

Parser
in package

Based on PEAR::Spreadsheet_Excel_Writer_Parser (by Xavier Noguer) Relicensed under the MIT License by the author.

Table of Contents

Constants

REGEX_CELL_TITLE_QUOTED  = "~^'" . self::REGEX_SHEET_TITLE_QUOTED . '(:' . self::REGEX_SHEET_TITLE_QUOTED . ')?' . "'!(*COMMIT)" . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . '$~u'
REGEX_RANGE_TITLE_QUOTED  = "~^'" . self::REGEX_SHEET_TITLE_QUOTED . '(:' . self::REGEX_SHEET_TITLE_QUOTED . ')?' . "'!(*COMMIT)" . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . ':' . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . '$~u'
REGEX_SHEET_TITLE_QUOTED  = "([^*:/\\\\?\\[\\]']|'')+"
REGEX_SHEET_TITLE_UNQUOTED  = '[^\*\:\/\\\\\\?\[\]\+\-\% \\\'\^\&\<\>\=\,\;\#\(\)\"\{\}]+'
Constants

Properties

$currentCharacter  : int
The index of the character we are currently looking at.
$currentToken  : string
The token we are working on.
$lookAhead  : string
The character ahead of the current char.
$parseTree  : array<string|int, mixed>|string
The parse tree to be generated.
$references  : array<int|string, int|string>
Array of sheet references in the form of REF structures.
$tryDefinedName  : bool

Methods

__construct()  : mixed
The class constructor.
matchCellSheetnameQuoted()  : bool
matchRangeSheetnameQuoted()  : bool
parse()  : bool
The parsing method. It parses a formula.
setExtSheet()  : void
This method is used to update the array of sheet names. It is called by the addWorksheet() method of the \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook class.
toReversePolish()  : string
Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack).

Constants

REGEX_CELL_TITLE_QUOTED

public mixed REGEX_CELL_TITLE_QUOTED = "~^'" . self::REGEX_SHEET_TITLE_QUOTED . '(:' . self::REGEX_SHEET_TITLE_QUOTED . ')?' . "'!(*COMMIT)" . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . '$~u'

REGEX_RANGE_TITLE_QUOTED

public mixed REGEX_RANGE_TITLE_QUOTED = "~^'" . self::REGEX_SHEET_TITLE_QUOTED . '(:' . self::REGEX_SHEET_TITLE_QUOTED . ')?' . "'!(*COMMIT)" . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . ':' . '[$]?[A-Ia-i]?[A-Za-z][$]?(\d+)' . '$~u'

REGEX_SHEET_TITLE_QUOTED

public mixed REGEX_SHEET_TITLE_QUOTED = "([^*:/\\\\?\\[\\]']|'')+"

REGEX_SHEET_TITLE_UNQUOTED

Constants

public mixed REGEX_SHEET_TITLE_UNQUOTED = '[^\*\:\/\\\\\\?\[\]\+\-\% \\\'\^\&\<\>\=\,\;\#\(\)\"\{\}]+'

Properties

$currentCharacter

The index of the character we are currently looking at.

public int $currentCharacter

$currentToken

The token we are working on.

public string $currentToken

$lookAhead

The character ahead of the current char.

public string $lookAhead

$parseTree

The parse tree to be generated.

public array<string|int, mixed>|string $parseTree

$references

Array of sheet references in the form of REF structures.

public array<int|string, int|string> $references

$tryDefinedName

protected bool $tryDefinedName = false

Methods

matchCellSheetnameQuoted()

public static matchCellSheetnameQuoted(string $token) : bool
Parameters
$token : string
Return values
bool

matchRangeSheetnameQuoted()

public static matchRangeSheetnameQuoted(string $token) : bool
Parameters
$token : string
Return values
bool

parse()

The parsing method. It parses a formula.

public parse(string $formula) : bool
Parameters
$formula : string

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

Return values
bool —

true on success

setExtSheet()

This method is used to update the array of sheet names. It is called by the addWorksheet() method of the \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook class.

public setExtSheet(string $name, int $index) : void
Parameters
$name : string

The name of the worksheet being added

$index : int

The index of the worksheet being added

Tags
see
Workbook::addWorksheet

toReversePolish()

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

public toReversePolish([array<string|int, mixed> $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

Parameters
$tree : array<string|int, mixed> = []

the optional tree to convert

Return values
string —

The tree in reverse polish notation


        
On this page

Search results