Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
PhpOffice\PhpSpreadsheet\Cell\Coordinate Class Reference

Static Public Member Functions

static absoluteCoordinate (string $cellAddress)
 Make string coordinate absolute.
 
static absoluteReference (int|string $cellAddress)
 Make string row, column or cell coordinate absolute.
 
static buildRange (array $range)
 Build range from coordinate strings.
 
static columnIndexFromString (?string $columnAddress)
 Column index from string.
 
static coordinateFromString (string $cellAddress)
 Convert string coordinate to [0 => int column index, 1 => int row index].
 
static coordinateIsInsideRange (string $range, string $coordinate)
 Check if coordinate is inside a range.
 
static coordinateIsRange (string $cellAddress)
 Checks if a Cell Address represents a range of cells.
 
static extractAllCellReferencesInRange (string $cellRange)
 Extract all cell references in range, which may be comprised of multiple cell ranges.
 
static getRangeBoundaries (string $range)
 Calculate range boundaries.
 
static indexesFromString (string $coordinates)
 Convert string coordinate to [0 => int column index, 1 => int row index, 2 => string column string].
 
static mergeRangesInCollection (array $coordinateCollection)
 Convert an associative array of single cell coordinates to values to an associative array of cell ranges to values.
 
static rangeBoundaries (string $range)
 Calculate range boundaries.
 
static rangeDimension (string $range)
 Calculate range dimension.
 
static resolveUnionAndIntersection (string $cellBlock, string $implodeCharacter=',')
 Get all cell references applying union and intersection.
 
static splitRange (string $range)
 Split range into coordinate strings.
 
static stringFromColumnIndex (int|string $columnIndex)
 String from column index.
 

Public Attributes

const A1_COORDINATE_REGEX = '/^(?<col>\$?[A-Z]{1,3})(?<row>\$?\d{1,7})$/i'
 
string const DEFAULT_RANGE = 'A1:A1'
 Default range variable constant.
 
const FULL_REFERENCE_REGEX = '/^(?:(?<worksheet>[^!]*)!)?(?<localReference>(?<firstCoordinate>[$]?[A-Z]{1,3}[$]?::d{1,7})(?::::(?<secondCoordinate>[$]?[A-Z]{1,3}[$]?::d{1,7}))?)$/i'
 

Member Function Documentation

◆ absoluteCoordinate()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::absoluteCoordinate ( string $cellAddress)
static

Make string coordinate absolute.

Parameters
string$cellAddresse.g. 'A1'
Return values
stringAbsolute coordinate e.g. '$A$1'

◆ absoluteReference()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::absoluteReference ( int|string $cellAddress)
static

Make string row, column or cell coordinate absolute.

Parameters
int | string$cellAddresse.g. 'A' or '1' or 'A1' Note that this value can be a row or column reference as well as a cell reference
Return values
stringAbsolute coordinate e.g. '$A' or '$1' or '$A$1'

◆ buildRange()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::buildRange ( array $range)
static

Build range from coordinate strings.

Parameters
array$rangeArray containing one or more arrays containing one or two coordinate strings
Return values
stringString representation of $pRange

◆ columnIndexFromString()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString ( ?string $columnAddress)
static

Column index from string.

Parameters
?string$columnAddresseg 'A'
Return values
intColumn index (A = 1)

◆ coordinateFromString()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::coordinateFromString ( string $cellAddress)
static

Convert string coordinate to [0 => int column index, 1 => int row index].

Parameters
string$cellAddresseg: 'A1'
Return values
array{0string, 1: string} Array containing column and row (indexes 0 and 1)

◆ coordinateIsInsideRange()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::coordinateIsInsideRange ( string $range,
string $coordinate )
static

Check if coordinate is inside a range.

Parameters
string$rangeCell range, Single Cell, Row/Column Range (e.g. A1:A1, B2, B:C, 2:3)
string$coordinateCell coordinate (e.g. A1)
Return values
booltrue if coordinate is inside range

◆ coordinateIsRange()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::coordinateIsRange ( string $cellAddress)
static

Checks if a Cell Address represents a range of cells.

Parameters
string$cellAddresseg: 'A1' or 'A1:A2' or 'A1:A2,C1:C2'
Return values
boolWhether the coordinate represents a range of cells

◆ extractAllCellReferencesInRange()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::extractAllCellReferencesInRange ( string $cellRange)
static

Extract all cell references in range, which may be comprised of multiple cell ranges.

Parameters
string$cellRangeRange: e.g. 'A1' or 'A1:C10' or 'A1:E10,A20:E25' or 'A1:E5 C3:G7' or 'A1:C1,A3:C3 B1:C3'
Return values
arrayArray containing single cell references

◆ getRangeBoundaries()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::getRangeBoundaries ( string $range)
static

Calculate range boundaries.

Parameters
string$rangeCell range, Single Cell, Row/Column Range (e.g. A1:A1, B2, B:C, 2:3)
Return values
arrayRange coordinates [Start Cell, End Cell] where Start Cell and End Cell are arrays [Column ID, Row Number]

◆ indexesFromString()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::indexesFromString ( string $coordinates)
static

Convert string coordinate to [0 => int column index, 1 => int row index, 2 => string column string].

Parameters
string$coordinateseg: 'A1', '$B$12'
Return values
array{0int, 1: int, 2: string} Array containing column and row index, and column string

◆ mergeRangesInCollection()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::mergeRangesInCollection ( array $coordinateCollection)
static

Convert an associative array of single cell coordinates to values to an associative array of cell ranges to values.

Only adjacent cell coordinates with the same value will be merged. If the value is an object, it must implement the method getHashCode().

For example, this function converts:

[ 'A1' => 'x', 'A2' => 'x', 'A3' => 'x', 'A4' => 'y' ]

to:

[ 'A1:A3' => 'x', 'A4' => 'y' ]

Parameters
array$coordinateCollectionassociative array mapping coordinates to values
Return values
arrayassociative array mapping coordinate ranges to valuea

◆ rangeBoundaries()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::rangeBoundaries ( string $range)
static

Calculate range boundaries.

Parameters
string$rangeCell range, Single Cell, Row/Column Range (e.g. A1:A1, B2, B:C, 2:3)
Return values
arrayRange coordinates [Start Cell, End Cell] where Start Cell and End Cell are arrays (Column Number, Row Number)

◆ rangeDimension()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::rangeDimension ( string $range)
static

Calculate range dimension.

Parameters
string$rangeCell range, Single Cell, Row/Column Range (e.g. A1:A1, B2, B:C, 2:3)
Return values
arrayRange dimension (width, height)

◆ resolveUnionAndIntersection()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::resolveUnionAndIntersection ( string $cellBlock,
string $implodeCharacter = ',' )
static

Get all cell references applying union and intersection.

Parameters
string$cellBlockA cell range e.g. A1:B5,D1:E5 B2:C4
Return values
stringA string without intersection operator. If there was no intersection to begin with, return original argument. Otherwise, return cells and/or cell ranges in that range separated by comma.

◆ splitRange()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::splitRange ( string $range)
static

Split range into coordinate strings.

Parameters
string$rangee.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
Return values
arrayArray containing one or more arrays containing one or two coordinate strings e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']] or ['B4']

◆ stringFromColumnIndex()

static PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex ( int|string $columnIndex)
static

String from column index.

Parameters
int | numeric-string$columnIndexColumn index (A = 1)

The documentation for this class was generated from the following file: