Documentation

ReferenceHelper

Table of Contents

REFHELPER_REGEXP_CELLREF Regular Expressions '((\\w*|\'[^!]*\')!)?(?<![:a-z\\$])(\\$?[a-z]{1,3}\\$?\\d+)(?=[^:!\\d\'])'
REFHELPER_REGEXP_CELLRANGE '((\\w*|\'[^!]*\')!)?(\\$?[a-z]{1,3}\\$?\\d+):(\\$?[a-z]{1,3}\\$?\\d+)'
REFHELPER_REGEXP_ROWRANGE '((\\w*|\'[^!]*\')!)?(\\$?\\d+):(\\$?\\d+)'
REFHELPER_REGEXP_COLRANGE '((\\w*|\'[^!]*\')!)?(\\$?[a-z]{1,3}):(\\$?[a-z]{1,3})'
$instance Instance of this class. ReferenceHelper
getInstance() Get an instance of this class. ReferenceHelper
__construct() Create a new ReferenceHelper. mixed
columnSort() Compare two column addresses Intended for use as a Callback function for sorting column addresses by column. int
columnReverseSort() Compare two column addresses Intended for use as a Callback function for reverse sorting column addresses by column. int
cellSort() Compare two cell addresses Intended for use as a Callback function for sorting cell addresses by column and row. int
cellReverseSort() Compare two cell addresses Intended for use as a Callback function for sorting cell addresses by column and row. int
cellAddressInDeleteRange() Test whether a cell address falls within a defined range of cells. bool
adjustPageBreaks() Update page breaks when inserting/deleting rows/columns. void
adjustComments() Update cell comments when inserting/deleting rows/columns. void
adjustHyperlinks() Update hyperlinks when inserting/deleting rows/columns. void
adjustDataValidations() Update data validations when inserting/deleting rows/columns. void
adjustMergeCells() Update merged cells when inserting/deleting rows/columns. void
adjustProtectedCells() Update protected cells when inserting/deleting rows/columns. void
adjustColumnDimensions() Update column dimensions when inserting/deleting rows/columns. void
adjustRowDimensions() Update row dimensions when inserting/deleting rows/columns. void
insertNewBefore() Insert a new column or row, updating all possible related data. void
updateFormulaReferences() Update references within formulas. string
updateFormulaReferencesAnyWorksheet() Update all cell references within a formula, irrespective of worksheet. string
updateCellReferencesAllWorksheets() string
updateColumnRangesAllWorksheets() string
updateRowRangesAllWorksheets() string
updateCellReference() Update cell reference. string
updateNamedFormulas() Update named formulas (i.e. containing worksheet references / named ranges). void
updateCellRange() Update cell range. string
updateSingleCellReference() Update single cell reference. string
__clone() __clone implementation. Cloning should not be allowed in a Singleton! mixed

Constants

REFHELPER_REGEXP_CELLREF

Regular Expressions

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

REFHELPER_REGEXP_CELLRANGE

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

REFHELPER_REGEXP_ROWRANGE

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

REFHELPER_REGEXP_COLRANGE

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

Properties

Methods

__construct()

Create a new ReferenceHelper.

protected __construct( ) : mixed
Return values
mixed

columnSort()

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

public static columnSort( $a : string , $b : string ) : int
Parameters
$a : string

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

$b : string

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

Return values
int

columnReverseSort()

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

public static columnReverseSort( $a : string , $b : string ) : int
Parameters
$a : string

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

$b : string

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

Return values
int

cellSort()

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

public static cellSort( $a : string , $b : string ) : int
Parameters
$a : string

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

$b : string

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

Return values
int

cellReverseSort()

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

public static cellReverseSort( $a : string , $b : string ) : int
Parameters
$a : string

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

$b : string

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

Return values
int

cellAddressInDeleteRange()

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

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

Address of the cell we're testing

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

$beforeColumnIndex : int

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

$pNumCols : int

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

Return values
bool

adjustPageBreaks()

Update page breaks when inserting/deleting rows/columns.

protected adjustPageBreaks( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustComments()

Update cell comments when inserting/deleting rows/columns.

protected adjustComments( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustHyperlinks()

Update hyperlinks when inserting/deleting rows/columns.

protected adjustHyperlinks( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustDataValidations()

Update data validations when inserting/deleting rows/columns.

protected adjustDataValidations( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustMergeCells()

Update merged cells when inserting/deleting rows/columns.

protected adjustMergeCells( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustProtectedCells()

Update protected cells when inserting/deleting rows/columns.

protected adjustProtectedCells( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustColumnDimensions()

Update column dimensions when inserting/deleting rows/columns.

protected adjustColumnDimensions( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

adjustRowDimensions()

Update row dimensions when inserting/deleting rows/columns.

protected adjustRowDimensions( $pSheet : Worksheet , $pBefore : string , $beforeColumnIndex : int , $pNumCols : int , $beforeRow : int , $pNumRows : int ) : void
Parameters
$pSheet : Worksheet

The worksheet that we're editing

$pBefore : string

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

$beforeColumnIndex : int

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

$pNumCols : int

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

$beforeRow : int

Number of the row we're inserting/deleting before

$pNumRows : int

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

insertNewBefore()

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

public insertNewBefore( $pBefore : string , $pNumCols : int , $pNumRows : int , $pSheet : Worksheet ) : void
Parameters
$pBefore : string

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

$pNumCols : int

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

$pNumRows : int

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

$pSheet : Worksheet

The worksheet that we're editing

updateFormulaReferences()

Update references within formulas.

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

Formula to update

$pBefore : string = 'A1'

Insert before this one

$pNumCols : int

Number of columns to insert

$pNumRows : int

Number of rows to insert

$sheetName : string = ''

Worksheet name/title

Return values
string —

Updated formula

updateFormulaReferencesAnyWorksheet()

Update all cell references within a formula, irrespective of worksheet.

public updateFormulaReferencesAnyWorksheet( [ $formula : string = '' ] , $insertColumns : int , $insertRows : int ) : string
Parameters
$formula : string = ''
$insertColumns : int
$insertRows : int
Return values
string

updateCellReferencesAllWorksheets()

private updateCellReferencesAllWorksheets( $formula : string , $insertColumns : int , $insertRows : int ) : string
Parameters
$formula : string
$insertColumns : int
$insertRows : int
Return values
string

updateColumnRangesAllWorksheets()

private updateColumnRangesAllWorksheets( $formula : string , $insertColumns : int ) : string
Parameters
$formula : string
$insertColumns : int
Return values
string

updateRowRangesAllWorksheets()

private updateRowRangesAllWorksheets( $formula : string , $insertRows : int ) : string
Parameters
$formula : string
$insertRows : int
Return values
string

updateCellReference()

Update cell reference.

public updateCellReference( [ $pCellRange : string = 'A1' ] [, $pBefore : string = 'A1' ] , $pNumCols : int , $pNumRows : int ) : string
Parameters
$pCellRange : string = 'A1'

Cell range

$pBefore : string = 'A1'

Insert before this one

$pNumCols : int

Number of columns to increment

$pNumRows : int

Number of rows to increment

Return values
string —

Updated cell range

updateNamedFormulas()

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

public updateNamedFormulas( $spreadsheet : Spreadsheet [, $oldName : string = '' ] [, $newName : string = '' ] ) : void
Parameters
$spreadsheet : Spreadsheet

Object to update

$oldName : string = ''

Old name (name to replace)

$newName : string = ''

New name

updateCellRange()

Update cell range.

private updateCellRange( [ $pCellRange : string = 'A1:A1' ] [, $pBefore : string = 'A1' ] , $pNumCols : int , $pNumRows : int ) : string
Parameters
$pCellRange : string = 'A1:A1'

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

$pBefore : string = 'A1'

Insert before this one

$pNumCols : int

Number of columns to increment

$pNumRows : int

Number of rows to increment

Return values
string —

Updated cell range

updateSingleCellReference()

Update single cell reference.

private updateSingleCellReference( [ $pCellReference : string = 'A1' ] [, $pBefore : string = 'A1' ] , $pNumCols : int , $pNumRows : int ) : string
Parameters
$pCellReference : string = 'A1'

Single cell reference

$pBefore : string = 'A1'

Insert before this one

$pNumCols : int

Number of columns to increment

$pNumRows : int

Number of rows to increment

Return values
string —

Updated cell reference

__clone()

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

public final __clone( ) : mixed
Return values
mixed

Search results