\PHPExcel_ReferenceHelper

PHPExcel_ReferenceHelper (Singleton)

Copyright (c) 2006 - 2015 PHPExcel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Summary

Methods
Properties
Constants
getInstance()
columnSort()
columnReverseSort()
cellSort()
cellReverseSort()
insertNewBefore()
updateFormulaReferences()
updateCellReference()
updateNamedFormulas()
__clone()
No public properties found
REFHELPER_REGEXP_CELLREF
REFHELPER_REGEXP_CELLRANGE
REFHELPER_REGEXP_ROWRANGE
REFHELPER_REGEXP_COLRANGE
__construct()
adjustPageBreaks()
adjustComments()
adjustHyperlinks()
adjustDataValidations()
adjustMergeCells()
adjustProtectedCells()
adjustColumnDimensions()
adjustRowDimensions()
No protected properties found
N/A
cellAddressInDeleteRange()
updateCellRange()
updateSingleCellReference()
$instance
N/A

Constants

REFHELPER_REGEXP_CELLREF

REFHELPER_REGEXP_CELLREF = '((\\w*|\'[^!]*\')!)?(?<![:a-z\\$])(\\$?[a-z]{1,3}\\$?\\d+)(?=[^:!\\d\'])'

Regular Expressions

REFHELPER_REGEXP_CELLRANGE

REFHELPER_REGEXP_CELLRANGE = '((\\w*|\'[^!]*\')!)?(\\$?[a-z]{1,3}\\$?\\d+):(\\$?[a-z]{1,3}\\$?\\d+)'

REFHELPER_REGEXP_ROWRANGE

REFHELPER_REGEXP_ROWRANGE = '((\\w*|\'[^!]*\')!)?(\\$?\\d+):(\\$?\\d+)'

REFHELPER_REGEXP_COLRANGE

REFHELPER_REGEXP_COLRANGE = '((\\w*|\'[^!]*\')!)?(\\$?[a-z]{1,3}):(\\$?[a-z]{1,3})'

Properties

Methods

getInstance()

getInstance() : \PHPExcel_ReferenceHelper

Get an instance of this class

Returns

\PHPExcel_ReferenceHelper —

columnSort()

columnSort(string  $a, string  $b) : int

Compare two column addresses Intended for use as a Callback function for sorting column addresses by column

Parameters

string $a

First column to test (e.g. 'AA')

string $b

Second column to test (e.g. 'Z')

Returns

int —

columnReverseSort()

columnReverseSort(string  $a, string  $b) : int

Compare two column addresses Intended for use as a Callback function for reverse sorting column addresses by column

Parameters

string $a

First column to test (e.g. 'AA')

string $b

Second column to test (e.g. 'Z')

Returns

int —

cellSort()

cellSort(string  $a, string  $b) : int

Compare two cell addresses Intended for use as a Callback function for sorting cell addresses by column and row

Parameters

string $a

First cell to test (e.g. 'AA1')

string $b

Second cell to test (e.g. 'Z1')

Returns

int —

cellReverseSort()

cellReverseSort(string  $a, string  $b) : int

Compare two cell addresses Intended for use as a Callback function for sorting cell addresses by column and row

Parameters

string $a

First cell to test (e.g. 'AA1')

string $b

Second cell to test (e.g. 'Z1')

Returns

int —

insertNewBefore()

insertNewBefore(string  $pBefore = 'A1', int  $pNumCols, int  $pNumRows, \PHPExcel_Worksheet  $pSheet = null) : mixed

Insert a new column or row, updating all possible related data

Parameters

string $pBefore

Insert before this cell address (e.g. 'A1')

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

Throws

\PHPExcel_Exception

Returns

mixed —

updateFormulaReferences()

updateFormulaReferences(string  $pFormula = '', int  $pBefore = 'A1', int  $pNumCols, int  $pNumRows, string  $sheetName = '') : string

Update references within formulas

Parameters

string $pFormula

Formula to update

int $pBefore

Insert before this one

int $pNumCols

Number of columns to insert

int $pNumRows

Number of rows to insert

string $sheetName

Worksheet name/title

Throws

\PHPExcel_Exception

Returns

string —

Updated formula

updateCellReference()

updateCellReference(string  $pCellRange = 'A1', int  $pBefore = 'A1', int  $pNumCols, int  $pNumRows) : string

Update cell reference

Parameters

string $pCellRange

Cell range

int $pBefore

Insert before this one

int $pNumCols

Number of columns to increment

int $pNumRows

Number of rows to increment

Throws

\PHPExcel_Exception

Returns

string —

Updated cell range

updateNamedFormulas()

updateNamedFormulas(\PHPExcel  $pPhpExcel, string  $oldName = '', string  $newName = '') : mixed

Update named formulas (i.e. containing worksheet references / named ranges)

Parameters

\PHPExcel $pPhpExcel

Object to update

string $oldName

Old name (name to replace)

string $newName

New name

Returns

mixed —

__clone()

__clone() : mixed

__clone implementation. Cloning should not be allowed in a Singleton!

Throws

\PHPExcel_Exception

Returns

mixed —

__construct()

__construct() : mixed

Create a new PHPExcel_ReferenceHelper

Returns

mixed —

adjustPageBreaks()

adjustPageBreaks(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update page breaks when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustComments()

adjustComments(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update cell comments when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustHyperlinks()

adjustHyperlinks(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update hyperlinks when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustDataValidations()

adjustDataValidations(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update data validations when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustMergeCells()

adjustMergeCells(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update merged cells when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustProtectedCells()

adjustProtectedCells(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update protected cells when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustColumnDimensions()

adjustColumnDimensions(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update column dimensions when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

adjustRowDimensions()

adjustRowDimensions(\PHPExcel_Worksheet  $pSheet, string  $pBefore, int  $beforeColumnIndex, int  $pNumCols, int  $beforeRow, int  $pNumRows) : mixed

Update row dimensions when inserting/deleting rows/columns

Parameters

\PHPExcel_Worksheet $pSheet

The worksheet that we're editing

string $pBefore

Insert/Delete before this cell address (e.g. 'A1')

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

Returns

mixed —

cellAddressInDeleteRange()

cellAddressInDeleteRange(string  $cellAddress, int  $beforeRow, int  $pNumRows, int  $beforeColumnIndex, int  $pNumCols) : bool

Test whether a cell address falls within a defined range of cells

Parameters

string $cellAddress

Address of the cell we're testing

int $beforeRow

Number of the row we're inserting/deleting before

int $pNumRows

Number of rows to insert/delete (negative values indicate deletion)

int $beforeColumnIndex

Index number of the column we're inserting/deleting before

int $pNumCols

Number of columns to insert/delete (negative values indicate deletion)

Returns

bool —

updateCellRange()

updateCellRange(string  $pCellRange = 'A1:A1', int  $pBefore = 'A1', int  $pNumCols, int  $pNumRows) : string

Update cell range

Parameters

string $pCellRange

Cell range (e.g. 'B2:D4', 'B:C' or '2:3')

int $pBefore

Insert before this one

int $pNumCols

Number of columns to increment

int $pNumRows

Number of rows to increment

Throws

\PHPExcel_Exception

Returns

string —

Updated cell range

updateSingleCellReference()

updateSingleCellReference(string  $pCellReference = 'A1', int  $pBefore = 'A1', int  $pNumCols, int  $pNumRows) : string

Update single cell reference

Parameters

string $pCellReference

Single cell reference

int $pBefore

Insert before this one

int $pNumCols

Number of columns to increment

int $pNumRows

Number of rows to increment

Throws

\PHPExcel_Exception

Returns

string —

Updated cell reference