Documentation

Worksheet implements IComparable

Interfaces, Classes and Traits

IComparable

Table of Contents

BREAK_COLUMN  = 2
BREAK_NONE  = 0
BREAK_ROW  = 1
SHEET_TITLE_MAXIMUM_LENGTH  = 31
Maximum 31 characters allowed for sheet title.
SHEETSTATE_HIDDEN  = 'hidden'
SHEETSTATE_VERYHIDDEN  = 'veryHidden'
SHEETSTATE_VISIBLE  = 'visible'
$activeCell  : string
Active cell. (Only one!).
$autoFilter  : AutoFilter
Autofilter Range and selection.
$breaks  : array<string|int, int>
Collection of breaks.
$cachedHighestColumn  : int
Cached highest column.
$cachedHighestRow  : int
Cached highest row.
$cellCollection  : Cells
Collection of cells.
$cellCollectionIsSorted  : bool
Is the current cell collection sorted already?
$chartCollection  : ArrayObject<string|int, Chart>
Collection of Chart objects.
$codeName  : string
CodeName.
$columnDimensions  : array<string|int, ColumnDimension>
Collection of column dimensions.
$comments  : array<string|int, Comment>
Collection of comments.
$conditionalStylesCollection  : array<string|int, mixed>
Conditional styles. Indexed by cell coordinate, e.g. 'A1'.
$dataValidationCollection  : array<string|int, mixed>
Data validation objects. Indexed by cell coordinate, e.g. 'A1'.
$defaultColumnDimension  : ColumnDimension
Default column dimension.
$defaultRowDimension  : RowDimension
Default row dimension.
$dirty  : bool
Dirty flag.
$drawingCollection  : ArrayObject<string|int, BaseDrawing>
Collection of drawings.
$freezePane  : null|string
Freeze pane.
$hash  : string
Hash.
$headerFooter  : HeaderFooter
Page header/footer.
$hyperlinkCollection  : array<string|int, mixed>
Hyperlinks. Indexed by cell coordinate, e.g. 'A1'.
$invalidCharacters  : array<string|int, mixed>
Invalid characters in sheet title.
$mergeCells  : array<string|int, string>
Collection of merged cell ranges.
$pageMargins  : PageMargins
Page margins.
$pageSetup  : PageSetup
Page setup.
$parent  : Spreadsheet
Parent spreadsheet.
$printGridlines  : bool
Print gridlines?
$protectedCells  : array<string|int, string>
Collection of protected cell ranges.
$protection  : Protection
Protection.
$rightToLeft  : bool
Right-to-left?
$rowDimensions  : array<string|int, RowDimension>
Collection of row dimensions.
$selectedCells  : string
Selected cells.
$sheetState  : string
Sheet state.
$sheetView  : SheetView
Sheet view.
$showGridlines  : bool
Show gridlines?
$showRowColHeaders  : bool
Show row and column headers?
$showSummaryBelow  : bool
Show summary below? (Row/Column outline).
$showSummaryRight  : bool
Show summary right? (Row/Column outline).
$styles  : array<string|int, Style>
Collection of styles.
$tabColor  : null|Color
Tab color.
$title  : string
Worksheet title.
$topLeftCell  : null|string
Default position of the right bottom pane.
__clone()  : mixed
Implement PHP __clone to create a deep clone, not just a shallow copy.
__construct()  : mixed
Create a new worksheet.
__destruct()  : mixed
Code to execute when this worksheet is unset().
addChart()  : Chart
Add chart.
calculateColumnWidths()  : $this
Calculate widths for auto-size columns.
calculateWorksheetDataDimension()  : string
Calculate worksheet data dimension.
calculateWorksheetDimension()  : string
Calculate worksheet dimension.
cellExists()  : bool
Does the cell at a specific coordinate exist?
cellExistsByColumnAndRow()  : bool
Cell at a specific coordinate by using numeric cell coordinates exists?
conditionalStylesExists()  : bool
Do conditional styles exist for this cell?
copy()  : static
Copy worksheet (!= clone!).
dataValidationExists()  : bool
Data validation at a specific coordinate exists?
disconnectCells()  : void
Disconnect all cells from this Worksheet object, typically so that the worksheet object can be unset.
duplicateConditionalStyle()  : $this
Duplicate conditional style to a range of cells.
duplicateStyle()  : $this
Duplicate cell style to a range of cells.
extractSheetTitle()  : mixed
Extract worksheet title from range.
freezePane()  : $this
Freeze Pane.
freezePaneByColumnAndRow()  : $this
Freeze Pane by using numeric cell coordinates.
fromArray()  : $this
Fill worksheet from values in array.
garbageCollect()  : $this
Run PhpSpreadsheet garbage collector.
getActiveCell()  : string
Get active cell.
getAutoFilter()  : AutoFilter
Get Autofilter.
getBreaks()  : array<string|int, int>
Get breaks.
getCell()  : Cell
Get cell at a specific coordinate.
getCellByColumnAndRow()  : Cell
Get cell at a specific coordinate by using numeric cell coordinates.
getCellCollection()  : Cells
Return the cell collection.
getChartByIndex()  : Chart|false
Get a chart by its index position.
getChartByName()  : Chart|false
Get a chart by name.
getChartCollection()  : ArrayObject<string|int, Chart>
Get collection of charts.
getChartCount()  : int
Return the count of charts on this worksheet.
getChartNames()  : array<string|int, string>
Return an array of the names of charts on this worksheet.
getCodeName()  : null|string
Return the code name of the sheet.
getColumnDimension()  : ColumnDimension
Get column dimension at a specific column.
getColumnDimensionByColumn()  : ColumnDimension
Get column dimension at a specific column by using numeric cell coordinates.
getColumnDimensions()  : array<string|int, ColumnDimension>
Get collection of column dimensions.
getColumnIterator()  : ColumnIterator
Get column iterator.
getComment()  : Comment
Get comment for cell.
getCommentByColumnAndRow()  : Comment
Get comment for cell by using numeric cell coordinates.
getComments()  : array<string|int, Comment>
Get comments.
getConditionalStyles()  : array<string|int, Conditional>
Get conditional styles for a cell.
getConditionalStylesCollection()  : array<string|int, mixed>
Get collection of conditional styles.
getCoordinates()  : array<string|int, string>
Get a sorted list of all cell coordinates currently held in the collection by row and column.
getDataValidation()  : DataValidation
Get data validation.
getDataValidationCollection()  : array<string|int, DataValidation>
Get collection of data validations.
getDefaultColumnDimension()  : ColumnDimension
Get default column dimension.
getDefaultRowDimension()  : RowDimension
Get default row dimension.
getDrawingCollection()  : ArrayObject<string|int, BaseDrawing>
Get collection of drawings.
getFreezePane()  : string
Get Freeze Pane.
getHashCode()  : string
Get hash code.
getHeaderFooter()  : HeaderFooter
Get page header/footer.
getHighestColumn()  : string
Get highest worksheet column.
getHighestDataColumn()  : string
Get highest worksheet column that contains data.
getHighestDataRow()  : int
Get highest worksheet row that contains data.
getHighestRow()  : int
Get highest worksheet row.
getHighestRowAndColumn()  : array<string|int, mixed>
Get highest worksheet column and highest row that have cell records.
getHyperlink()  : Hyperlink
Get hyperlink.
getHyperlinkCollection()  : array<string|int, Hyperlink>
Get collection of hyperlinks.
getInvalidCharacters()  : array<string|int, mixed>
Get array of invalid characters for sheet title.
getMergeCells()  : array<string|int, string>
Get merge cells array.
getPageMargins()  : PageMargins
Get page margins.
getPageSetup()  : PageSetup
Get page setup.
getParent()  : Spreadsheet
Get parent.
getPrintGridlines()  : bool
Print gridlines?
getProtectedCells()  : array<string|int, string>
Get protected cells.
getProtection()  : Protection
Get Protection.
getRightToLeft()  : bool
Get right-to-left.
getRowDimension()  : RowDimension
Get row dimension at a specific row.
getRowDimensions()  : array<string|int, RowDimension>
Get collection of row dimensions.
getRowIterator()  : RowIterator
Get row iterator.
getSelectedCells()  : string
Get selected cells.
getSheetState()  : string
Get sheet state.
getSheetView()  : SheetView
Get sheet view.
getShowGridlines()  : bool
Show gridlines?
getShowRowColHeaders()  : bool
Show row and column headers?
getShowSummaryBelow()  : bool
Show summary below? (Row/Column outlining).
getShowSummaryRight()  : bool
Show summary right? (Row/Column outlining).
getStyle()  : Style
Get style for cell.
getStyleByColumnAndRow()  : Style
Get style for cell by using numeric cell coordinates.
getStyles()  : array<string|int, Style>
Get styles.
getTabColor()  : Color
Get tab color.
getTitle()  : string
Get title.
getTopLeftCell()  : null|string
Get the default position of the right bottom pane.
hasCodeName()  : bool
Sheet has a code name ?
hyperlinkExists()  : bool
Hyperlink at a specific coordinate exists?
insertNewColumnBefore()  : $this
Insert a new column, updating all possible related data.
insertNewColumnBeforeByIndex()  : $this
Insert a new column, updating all possible related data.
insertNewRowBefore()  : $this
Insert a new row, updating all possible related data.
isTabColorSet()  : bool
Tab color set?
mergeCells()  : $this
Set merge on a cell range.
mergeCellsByColumnAndRow()  : $this
Set merge on a cell range by using numeric cell coordinates.
namedRangeToArray()  : array<string|int, mixed>
Create array from a range of cells.
protectCells()  : $this
Set protection on a cell range.
protectCellsByColumnAndRow()  : $this
Set protection on a cell range by using numeric cell coordinates.
rangeToArray()  : array<string|int, mixed>
Create array from a range of cells.
rebindParent()  : $this
Re-bind parent.
refreshColumnDimensions()  : $this
Refresh column dimensions.
refreshRowDimensions()  : $this
Refresh row dimensions.
removeAutoFilter()  : $this
Remove autofilter.
removeColumn()  : $this
Remove a column, updating all possible related data.
removeColumnByIndex()  : $this
Remove a column, updating all possible related data.
removeConditionalStyles()  : $this
Removes conditional styles for a cell.
removeRow()  : $this
Delete a row, updating all possible related data.
resetTabColor()  : $this
Reset tab color.
setAutoFilter()  : $this
Set AutoFilter.
setAutoFilterByColumnAndRow()  : $this
Set Autofilter Range by using numeric cell coordinates.
setBreak()  : $this
Set break on a cell.
setBreakByColumnAndRow()  : $this
Set break on a cell by using numeric cell coordinates.
setCellValue()  : $this
Set a cell value.
setCellValueByColumnAndRow()  : $this
Set a cell value by using numeric cell coordinates.
setCellValueExplicit()  : $this
Set a cell value.
setCellValueExplicitByColumnAndRow()  : $this
Set a cell value by using numeric cell coordinates.
setCodeName()  : $this
Define the code name of the sheet.
setComments()  : $this
Set comments array for the entire sheet.
setConditionalStyles()  : $this
Set conditional styles.
setDataValidation()  : $this
Set data validation.
setHeaderFooter()  : $this
Set page header/footer.
setHyperlink()  : $this
Set hyperlink.
setMergeCells()  : $this
Set merge cells array for the entire sheet. Use instead mergeCells() to merge a single cell range.
setPageMargins()  : $this
Set page margins.
setPageSetup()  : $this
Set page setup.
setPrintGridlines()  : $this
Set print gridlines.
setProtection()  : $this
Set Protection.
setRightToLeft()  : $this
Set right-to-left.
setSelectedCell()  : $this
Selected cell.
setSelectedCellByColumnAndRow()  : $this
Selected cell by using numeric cell coordinates.
setSelectedCells()  : $this
Select a range of cells.
setSheetState()  : $this
Set sheet state.
setSheetView()  : $this
Set sheet view.
setShowGridlines()  : $this
Set show gridlines.
setShowRowColHeaders()  : $this
Set show row and column headers.
setShowSummaryBelow()  : $this
Set show summary below.
setShowSummaryRight()  : $this
Set show summary right.
setTitle()  : $this
Set title.
shrinkRangeToFit()  : string
Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet.
toArray()  : array<string|int, mixed>
Create array from worksheet.
unfreezePane()  : $this
Unfreeze Pane.
unmergeCells()  : $this
Remove merge on a cell range.
unmergeCellsByColumnAndRow()  : $this
Remove merge on a cell range by using numeric cell coordinates.
unprotectCells()  : $this
Remove protection on a cell range.
unprotectCellsByColumnAndRow()  : $this
Remove protection on a cell range by using numeric cell coordinates.
checkSheetCodeName()  : string
Check sheet code name for valid Excel syntax.
checkSheetTitle()  : string
Check sheet title for valid Excel syntax.
createNewCell()  : Cell
Create a new cell at the specified coordinate.
getCellOrNull()  : null|Cell
Get an existing cell at a specific coordinate, or null.
getWorksheetAndCoordinate()  : array<string|int, mixed>
Get the correct Worksheet and coordinate from a coordinate that may contains reference to another sheet or a named range.
validateNamedRange()  : DefinedName|null

Constants

SHEET_TITLE_MAXIMUM_LENGTH

Maximum 31 characters allowed for sheet title.

public int SHEET_TITLE_MAXIMUM_LENGTH = 31

SHEETSTATE_HIDDEN

public mixed SHEETSTATE_HIDDEN = 'hidden'

SHEETSTATE_VERYHIDDEN

public mixed SHEETSTATE_VERYHIDDEN = 'veryHidden'

SHEETSTATE_VISIBLE

public mixed SHEETSTATE_VISIBLE = 'visible'

Properties

$activeCell

Active cell. (Only one!).

private string $activeCell = 'A1'

$breaks

Collection of breaks.

private array<string|int, int> $breaks = []

$cachedHighestColumn

Cached highest column.

private int $cachedHighestColumn = 1

$cachedHighestRow

Cached highest row.

private int $cachedHighestRow = 1

$cellCollectionIsSorted

Is the current cell collection sorted already?

private bool $cellCollectionIsSorted = false

$chartCollection

Collection of Chart objects.

private ArrayObject<string|int, Chart> $chartCollection

$codeName

CodeName.

private string $codeName

$comments

Collection of comments.

private array<string|int, Comment> $comments = []

$conditionalStylesCollection

Conditional styles. Indexed by cell coordinate, e.g. 'A1'.

private array<string|int, mixed> $conditionalStylesCollection = []

$dataValidationCollection

Data validation objects. Indexed by cell coordinate, e.g. 'A1'.

private array<string|int, mixed> $dataValidationCollection = []

$dirty

Dirty flag.

private bool $dirty = true

$drawingCollection

Collection of drawings.

private ArrayObject<string|int, BaseDrawing> $drawingCollection

$freezePane

Freeze pane.

private null|string $freezePane

$hyperlinkCollection

Hyperlinks. Indexed by cell coordinate, e.g. 'A1'.

private array<string|int, mixed> $hyperlinkCollection = []

$invalidCharacters

Invalid characters in sheet title.

private static array<string|int, mixed> $invalidCharacters = ['*', ':', '/', '\', '?', '[', ']']

$mergeCells

Collection of merged cell ranges.

private array<string|int, string> $mergeCells = []

$printGridlines

Print gridlines?

private bool $printGridlines = false

$protectedCells

Collection of protected cell ranges.

private array<string|int, string> $protectedCells = []

$rightToLeft

Right-to-left?

private bool $rightToLeft = false

$rowDimensions

Collection of row dimensions.

private array<string|int, RowDimension> $rowDimensions = []

$selectedCells

Selected cells.

private string $selectedCells = 'A1'

$sheetState

Sheet state.

private string $sheetState

$showGridlines

Show gridlines?

private bool $showGridlines = true

$showRowColHeaders

Show row and column headers?

private bool $showRowColHeaders = true

$showSummaryBelow

Show summary below? (Row/Column outline).

private bool $showSummaryBelow = true

$showSummaryRight

Show summary right? (Row/Column outline).

private bool $showSummaryRight = true

$styles

Collection of styles.

private array<string|int, Style> $styles = []

$title

Worksheet title.

private string $title

$topLeftCell

Default position of the right bottom pane.

private null|string $topLeftCell

Methods

__clone()

Implement PHP __clone to create a deep clone, not just a shallow copy.

public __clone() : mixed
Return values
mixed

__construct()

Create a new worksheet.

public __construct([Spreadsheet $parent = null ][, string $pTitle = 'Worksheet' ]) : mixed
Parameters
$parent : Spreadsheet = null
$pTitle : string = 'Worksheet'
Return values
mixed

__destruct()

Code to execute when this worksheet is unset().

public __destruct() : mixed
Return values
mixed

addChart()

Add chart.

public addChart(Chart $pChart[, null|int $iChartIndex = null ]) : Chart
Parameters
$pChart : Chart
$iChartIndex : null|int = null

Index where chart should go (0,1,..., or null for last)

Return values
Chart

calculateColumnWidths()

Calculate widths for auto-size columns.

public calculateColumnWidths() : $this
Return values
$this

calculateWorksheetDataDimension()

Calculate worksheet data dimension.

public calculateWorksheetDataDimension() : string
Return values
string

String containing the dimension of this worksheet that actually contain data

calculateWorksheetDimension()

Calculate worksheet dimension.

public calculateWorksheetDimension() : string
Return values
string

String containing the dimension of this worksheet

cellExists()

Does the cell at a specific coordinate exist?

public cellExists(string $coordinate) : bool
Parameters
$coordinate : string

Coordinate of the cell eg: 'A1'

Return values
bool

cellExistsByColumnAndRow()

Cell at a specific coordinate by using numeric cell coordinates exists?

public cellExistsByColumnAndRow(int $columnIndex, int $row) : bool
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

Return values
bool

conditionalStylesExists()

Do conditional styles exist for this cell?

public conditionalStylesExists(string $pCoordinate) : bool
Parameters
$pCoordinate : string

eg: 'A1'

Return values
bool

copy()

Copy worksheet (!= clone!).

public copy() : static
Return values
static

dataValidationExists()

Data validation at a specific coordinate exists?

public dataValidationExists(string $pCoordinate) : bool
Parameters
$pCoordinate : string

eg: 'A1'

Return values
bool

disconnectCells()

Disconnect all cells from this Worksheet object, typically so that the worksheet object can be unset.

public disconnectCells() : void
Return values
void

duplicateConditionalStyle()

Duplicate conditional style to a range of cells.

public duplicateConditionalStyle(array<string|int, Conditional$pCellStyle[, string $pRange = '' ]) : $this

Please note that this will overwrite existing cell styles for cells in range!

Parameters
$pCellStyle : array<string|int, Conditional>

Cell style to duplicate

$pRange : string = ''

Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

Return values
$this

duplicateStyle()

Duplicate cell style to a range of cells.

public duplicateStyle(Style $pCellStyle, string $pRange) : $this

Please note that this will overwrite existing cell styles for cells in range!

Parameters
$pCellStyle : Style

Cell style to duplicate

$pRange : string

Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

Return values
$this

extractSheetTitle()

Extract worksheet title from range.

public static extractSheetTitle(string $pRange[, bool $returnRange = false ]) : mixed

Example: extractSheetTitle("testSheet!A1") ==> 'A1' Example: extractSheetTitle("'testSheet 1'!A1", true) ==> ['testSheet 1', 'A1'];

Parameters
$pRange : string

Range to extract title from

$returnRange : bool = false

Return range? (see example)

Return values
mixed

freezePane()

Freeze Pane.

public freezePane(null|string $cell[, null|string $topLeftCell = null ]) : $this

Examples:

  • A2 will freeze the rows above cell A2 (i.e row 1)
  • B1 will freeze the columns to the left of cell B1 (i.e column A)
  • B2 will freeze the rows above and to the left of cell B2 (i.e row 1 and column A)
Parameters
$cell : null|string

Position of the split

$topLeftCell : null|string = null

default position of the right bottom pane

Return values
$this

freezePaneByColumnAndRow()

Freeze Pane by using numeric cell coordinates.

public freezePaneByColumnAndRow(int $columnIndex, int $row) : $this
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

Return values
$this

fromArray()

Fill worksheet from values in array.

public fromArray(array<string|int, mixed> $source[, mixed $nullValue = null ][, string $startCell = 'A1' ][, bool $strictNullComparison = false ]) : $this
Parameters
$source : array<string|int, mixed>

Source array

$nullValue : mixed = null

Value in source array that stands for blank cell

$startCell : string = 'A1'

Insert array starting from this cell address as the top left coordinate

$strictNullComparison : bool = false

Apply strict comparison when testing for null values in the array

Return values
$this

garbageCollect()

Run PhpSpreadsheet garbage collector.

public garbageCollect() : $this
Return values
$this

getActiveCell()

Get active cell.

public getActiveCell() : string
Return values
string

Example: 'A1'

getBreaks()

Get breaks.

public getBreaks() : array<string|int, int>
Return values
array<string|int, int>

getCell()

Get cell at a specific coordinate.

public getCell(string $coordinate) : Cell
Parameters
$coordinate : string

Coordinate of the cell, eg: 'A1'

Return values
Cell

Cell that was found or created

getCellByColumnAndRow()

Get cell at a specific coordinate by using numeric cell coordinates.

public getCellByColumnAndRow(int $columnIndex, int $row) : Cell
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

Return values
Cell

Cell that was found/created or null

getCellCollection()

Return the cell collection.

public getCellCollection() : Cells
Return values
Cells

getChartByIndex()

Get a chart by its index position.

public getChartByIndex(string $index) : Chart|false
Parameters
$index : string

Chart index position

Return values
Chart|false

getChartByName()

Get a chart by name.

public getChartByName(string $chartName) : Chart|false
Parameters
$chartName : string

Chart name

Return values
Chart|false

getChartCollection()

Get collection of charts.

public getChartCollection() : ArrayObject<string|int, Chart>
Return values
ArrayObject<string|int, Chart>

getChartCount()

Return the count of charts on this worksheet.

public getChartCount() : int
Return values
int

The number of charts

getChartNames()

Return an array of the names of charts on this worksheet.

public getChartNames() : array<string|int, string>
Return values
array<string|int, string>

The names of charts

getCodeName()

Return the code name of the sheet.

public getCodeName() : null|string
Return values
null|string

getColumnDimension()

Get column dimension at a specific column.

public getColumnDimension(string $pColumn) : ColumnDimension
Parameters
$pColumn : string

String index of the column eg: 'A'

Return values
ColumnDimension

getColumnDimensionByColumn()

Get column dimension at a specific column by using numeric cell coordinates.

public getColumnDimensionByColumn(int $columnIndex) : ColumnDimension
Parameters
$columnIndex : int

Numeric column coordinate of the cell

Return values
ColumnDimension

getColumnIterator()

Get column iterator.

public getColumnIterator([string $startColumn = 'A' ][, string $endColumn = null ]) : ColumnIterator
Parameters
$startColumn : string = 'A'

The column address at which to start iterating

$endColumn : string = null

The column address at which to stop iterating

Return values
ColumnIterator

getComment()

Get comment for cell.

public getComment(string $pCellCoordinate) : Comment
Parameters
$pCellCoordinate : string

Cell coordinate to get comment for, eg: 'A1'

Return values
Comment

getCommentByColumnAndRow()

Get comment for cell by using numeric cell coordinates.

public getCommentByColumnAndRow(int $columnIndex, int $row) : Comment
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

Return values
Comment

getComments()

Get comments.

public getComments() : array<string|int, Comment>
Return values
array<string|int, Comment>

getConditionalStyles()

Get conditional styles for a cell.

public getConditionalStyles(string $pCoordinate) : array<string|int, Conditional>
Parameters
$pCoordinate : string

eg: 'A1'

Return values
array<string|int, Conditional>

getConditionalStylesCollection()

Get collection of conditional styles.

public getConditionalStylesCollection() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCoordinates()

Get a sorted list of all cell coordinates currently held in the collection by row and column.

public getCoordinates([bool $sorted = true ]) : array<string|int, string>
Parameters
$sorted : bool = true

Also sort the cell collection?

Return values
array<string|int, string>

getDataValidation()

Get data validation.

public getDataValidation(string $pCellCoordinate) : DataValidation
Parameters
$pCellCoordinate : string

Cell coordinate to get data validation for, eg: 'A1'

Return values
DataValidation

getDataValidationCollection()

Get collection of data validations.

public getDataValidationCollection() : array<string|int, DataValidation>
Return values
array<string|int, DataValidation>

getDrawingCollection()

Get collection of drawings.

public getDrawingCollection() : ArrayObject<string|int, BaseDrawing>
Return values
ArrayObject<string|int, BaseDrawing>

getFreezePane()

Get Freeze Pane.

public getFreezePane() : string
Return values
string

getHashCode()

Get hash code.

public getHashCode() : string
Return values
string

Hash code

getHighestColumn()

Get highest worksheet column.

public getHighestColumn([string $row = null ]) : string
Parameters
$row : string = null

Return the data highest column for the specified row, or the highest column of any row if no row number is passed

Return values
string

Highest column name

getHighestDataColumn()

Get highest worksheet column that contains data.

public getHighestDataColumn([string $row = null ]) : string
Parameters
$row : string = null

Return the highest data column for the specified row, or the highest data column of any row if no row number is passed

Return values
string

Highest column name that contains data

getHighestDataRow()

Get highest worksheet row that contains data.

public getHighestDataRow([string $column = null ]) : int
Parameters
$column : string = null

Return the highest data row for the specified column, or the highest data row of any column if no column letter is passed

Return values
int

Highest row number that contains data

getHighestRow()

Get highest worksheet row.

public getHighestRow([string $column = null ]) : int
Parameters
$column : string = null

Return the highest data row for the specified column, or the highest row of any column if no column letter is passed

Return values
int

Highest row number

getHighestRowAndColumn()

Get highest worksheet column and highest row that have cell records.

public getHighestRowAndColumn() : array<string|int, mixed>
Return values
array<string|int, mixed>

Highest column name and highest row number

Get hyperlink.

public getHyperlink(string $pCellCoordinate) : Hyperlink
Parameters
$pCellCoordinate : string

Cell coordinate to get hyperlink for, eg: 'A1'

Return values
Hyperlink

getHyperlinkCollection()

Get collection of hyperlinks.

public getHyperlinkCollection() : array<string|int, Hyperlink>
Return values
array<string|int, Hyperlink>

getInvalidCharacters()

Get array of invalid characters for sheet title.

public static getInvalidCharacters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMergeCells()

Get merge cells array.

public getMergeCells() : array<string|int, string>
Return values
array<string|int, string>

getPrintGridlines()

Print gridlines?

public getPrintGridlines() : bool
Return values
bool

getProtectedCells()

Get protected cells.

public getProtectedCells() : array<string|int, string>
Return values
array<string|int, string>

getRightToLeft()

Get right-to-left.

public getRightToLeft() : bool
Return values
bool

getRowDimension()

Get row dimension at a specific row.

public getRowDimension(int $pRow) : RowDimension
Parameters
$pRow : int

Numeric index of the row

Return values
RowDimension

getRowIterator()

Get row iterator.

public getRowIterator([int $startRow = 1 ][, int $endRow = null ]) : RowIterator
Parameters
$startRow : int = 1

The row number at which to start iterating

$endRow : int = null

The row number at which to stop iterating

Return values
RowIterator

getSelectedCells()

Get selected cells.

public getSelectedCells() : string
Return values
string

getSheetState()

Get sheet state.

public getSheetState() : string
Return values
string

Sheet state (visible, hidden, veryHidden)

getShowGridlines()

Show gridlines?

public getShowGridlines() : bool
Return values
bool

getShowRowColHeaders()

Show row and column headers?

public getShowRowColHeaders() : bool
Return values
bool

getShowSummaryBelow()

Show summary below? (Row/Column outlining).

public getShowSummaryBelow() : bool
Return values
bool

getShowSummaryRight()

Show summary right? (Row/Column outlining).

public getShowSummaryRight() : bool
Return values
bool

getStyle()

Get style for cell.

public getStyle(string $pCellCoordinate) : Style
Parameters
$pCellCoordinate : string

Cell coordinate (or range) to get style for, eg: 'A1'

Return values
Style

getStyleByColumnAndRow()

Get style for cell by using numeric cell coordinates.

public getStyleByColumnAndRow(int $columnIndex1, int $row1[, null|int $columnIndex2 = null ][, null|int $row2 = null ]) : Style
Parameters
$columnIndex1 : int

Numeric column coordinate of the cell

$row1 : int

Numeric row coordinate of the cell

$columnIndex2 : null|int = null

Numeric column coordinate of the range cell

$row2 : null|int = null

Numeric row coordinate of the range cell

Return values
Style

getStyles()

Get styles.

public getStyles() : array<string|int, Style>
Return values
array<string|int, Style>

getTitle()

Get title.

public getTitle() : string
Return values
string

getTopLeftCell()

Get the default position of the right bottom pane.

public getTopLeftCell() : null|string
Return values
null|string

hasCodeName()

Sheet has a code name ?

public hasCodeName() : bool
Return values
bool

hyperlinkExists()

Hyperlink at a specific coordinate exists?

public hyperlinkExists(string $pCoordinate) : bool
Parameters
$pCoordinate : string

eg: 'A1'

Return values
bool

insertNewColumnBefore()

Insert a new column, updating all possible related data.

public insertNewColumnBefore(string $pBefore[, int $pNumCols = 1 ]) : $this
Parameters
$pBefore : string

Insert before this one, eg: 'A'

$pNumCols : int = 1

Number of columns to insert

Return values
$this

insertNewColumnBeforeByIndex()

Insert a new column, updating all possible related data.

public insertNewColumnBeforeByIndex(int $beforeColumnIndex[, int $pNumCols = 1 ]) : $this
Parameters
$beforeColumnIndex : int

Insert before this one (numeric column coordinate of the cell)

$pNumCols : int = 1

Number of columns to insert

Return values
$this

insertNewRowBefore()

Insert a new row, updating all possible related data.

public insertNewRowBefore(int $pBefore[, int $pNumRows = 1 ]) : $this
Parameters
$pBefore : int

Insert before this one

$pNumRows : int = 1

Number of rows to insert

Return values
$this

isTabColorSet()

Tab color set?

public isTabColorSet() : bool
Return values
bool

mergeCells()

Set merge on a cell range.

public mergeCells(string $pRange) : $this
Parameters
$pRange : string

Cell range (e.g. A1:E1)

Return values
$this

mergeCellsByColumnAndRow()

Set merge on a cell range by using numeric cell coordinates.

public mergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2) : $this
Parameters
$columnIndex1 : int

Numeric column coordinate of the first cell

$row1 : int

Numeric row coordinate of the first cell

$columnIndex2 : int

Numeric column coordinate of the last cell

$row2 : int

Numeric row coordinate of the last cell

Return values
$this

namedRangeToArray()

Create array from a range of cells.

public namedRangeToArray(string $definedName[, mixed $nullValue = null ][, bool $calculateFormulas = true ][, bool $formatData = true ][, bool $returnCellRef = false ]) : array<string|int, mixed>
Parameters
$definedName : string

The Named Range that should be returned

$nullValue : mixed = null

Value returned in the array entry if a cell doesn't exist

$calculateFormulas : bool = true

Should formulas be calculated?

$formatData : bool = true

Should formatting be applied to cell values?

$returnCellRef : bool = false

False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return values
array<string|int, mixed>

protectCells()

Set protection on a cell range.

public protectCells(string $pRange, string $pPassword[, bool $pAlreadyHashed = false ]) : $this
Parameters
$pRange : string

Cell (e.g. A1) or cell range (e.g. A1:E1)

$pPassword : string

Password to unlock the protection

$pAlreadyHashed : bool = false

If the password has already been hashed, set this to true

Return values
$this

protectCellsByColumnAndRow()

Set protection on a cell range by using numeric cell coordinates.

public protectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2, string $password[, bool $alreadyHashed = false ]) : $this
Parameters
$columnIndex1 : int

Numeric column coordinate of the first cell

$row1 : int

Numeric row coordinate of the first cell

$columnIndex2 : int

Numeric column coordinate of the last cell

$row2 : int

Numeric row coordinate of the last cell

$password : string

Password to unlock the protection

$alreadyHashed : bool = false

If the password has already been hashed, set this to true

Return values
$this

rangeToArray()

Create array from a range of cells.

public rangeToArray(string $pRange[, mixed $nullValue = null ][, bool $calculateFormulas = true ][, bool $formatData = true ][, bool $returnCellRef = false ]) : array<string|int, mixed>
Parameters
$pRange : string

Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

$nullValue : mixed = null

Value returned in the array entry if a cell doesn't exist

$calculateFormulas : bool = true

Should formulas be calculated?

$formatData : bool = true

Should formatting be applied to cell values?

$returnCellRef : bool = false

False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return values
array<string|int, mixed>

refreshColumnDimensions()

Refresh column dimensions.

public refreshColumnDimensions() : $this
Return values
$this

refreshRowDimensions()

Refresh row dimensions.

public refreshRowDimensions() : $this
Return values
$this

removeAutoFilter()

Remove autofilter.

public removeAutoFilter() : $this
Return values
$this

removeColumn()

Remove a column, updating all possible related data.

public removeColumn(string $pColumn[, int $pNumCols = 1 ]) : $this
Parameters
$pColumn : string

Remove starting with this one, eg: 'A'

$pNumCols : int = 1

Number of columns to remove

Return values
$this

removeColumnByIndex()

Remove a column, updating all possible related data.

public removeColumnByIndex(int $columnIndex[, int $numColumns = 1 ]) : $this
Parameters
$columnIndex : int

Remove starting with this one (numeric column coordinate of the cell)

$numColumns : int = 1

Number of columns to remove

Return values
$this

removeConditionalStyles()

Removes conditional styles for a cell.

public removeConditionalStyles(string $pCoordinate) : $this
Parameters
$pCoordinate : string

eg: 'A1'

Return values
$this

removeRow()

Delete a row, updating all possible related data.

public removeRow(int $pRow[, int $pNumRows = 1 ]) : $this
Parameters
$pRow : int

Remove starting with this one

$pNumRows : int = 1

Number of rows to remove

Return values
$this

resetTabColor()

Reset tab color.

public resetTabColor() : $this
Return values
$this

setAutoFilter()

Set AutoFilter.

public setAutoFilter(AutoFilter|string $pValue) : $this
Parameters
$pValue : AutoFilter|string

A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility

Return values
$this

setAutoFilterByColumnAndRow()

Set Autofilter Range by using numeric cell coordinates.

public setAutoFilterByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2) : $this
Parameters
$columnIndex1 : int

Numeric column coordinate of the first cell

$row1 : int

Numeric row coordinate of the first cell

$columnIndex2 : int

Numeric column coordinate of the second cell

$row2 : int

Numeric row coordinate of the second cell

Return values
$this

setBreak()

Set break on a cell.

public setBreak(string $pCoordinate, int $pBreak) : $this
Parameters
$pCoordinate : string

Cell coordinate (e.g. A1)

$pBreak : int

Break type (type of Worksheet::BREAK_*)

Return values
$this

setBreakByColumnAndRow()

Set break on a cell by using numeric cell coordinates.

public setBreakByColumnAndRow(int $columnIndex, int $row, int $break) : $this
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

$break : int

Break type (type of Worksheet::BREAK_*)

Return values
$this

setCellValue()

Set a cell value.

public setCellValue(string $pCoordinate, mixed $pValue) : $this
Parameters
$pCoordinate : string

Coordinate of the cell, eg: 'A1'

$pValue : mixed

Value of the cell

Return values
$this

setCellValueByColumnAndRow()

Set a cell value by using numeric cell coordinates.

public setCellValueByColumnAndRow(int $columnIndex, int $row, mixed $value) : $this
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

$value : mixed

Value of the cell

Return values
$this

setCellValueExplicit()

Set a cell value.

public setCellValueExplicit(string $pCoordinate, mixed $pValue, string $pDataType) : $this
Parameters
$pCoordinate : string

Coordinate of the cell, eg: 'A1'

$pValue : mixed

Value of the cell

$pDataType : string

Explicit data type, see DataType::TYPE_*

Return values
$this

setCellValueExplicitByColumnAndRow()

Set a cell value by using numeric cell coordinates.

public setCellValueExplicitByColumnAndRow(int $columnIndex, int $row, mixed $value, string $dataType) : $this
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

$value : mixed

Value of the cell

$dataType : string

Explicit data type, see DataType::TYPE_*

Return values
$this

setCodeName()

Define the code name of the sheet.

public setCodeName(string $pValue[, bool $validate = true ]) : $this
Parameters
$pValue : string

Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)

$validate : bool = true

False to skip validation of new title. WARNING: This should only be set at parse time (by Readers), where titles can be assumed to be valid.

Return values
$this

setComments()

Set comments array for the entire sheet.

public setComments(array<string|int, Comment$pValue) : $this
Parameters
$pValue : array<string|int, Comment>
Return values
$this

setConditionalStyles()

Set conditional styles.

public setConditionalStyles(string $pCoordinate, array<string|int, Conditional$pValue) : $this
Parameters
$pCoordinate : string

eg: 'A1'

$pValue : array<string|int, Conditional>
Return values
$this

setDataValidation()

Set data validation.

public setDataValidation(string $pCellCoordinate[, DataValidation|null $pDataValidation = null ]) : $this
Parameters
$pCellCoordinate : string

Cell coordinate to insert data validation, eg: 'A1'

$pDataValidation : DataValidation|null = null
Return values
$this

Set hyperlink.

public setHyperlink(string $pCellCoordinate[, Hyperlink|null $pHyperlink = null ]) : $this
Parameters
$pCellCoordinate : string

Cell coordinate to insert hyperlink, eg: 'A1'

$pHyperlink : Hyperlink|null = null
Return values
$this

setMergeCells()

Set merge cells array for the entire sheet. Use instead mergeCells() to merge a single cell range.

public setMergeCells(array<string|int, string> $pValue) : $this
Parameters
$pValue : array<string|int, string>
Return values
$this

setPageSetup()

Set page setup.

public setPageSetup(PageSetup $pValue) : $this
Parameters
$pValue : PageSetup
Return values
$this

setPrintGridlines()

Set print gridlines.

public setPrintGridlines(bool $pValue) : $this
Parameters
$pValue : bool

Print gridlines (true/false)

Return values
$this

setRightToLeft()

Set right-to-left.

public setRightToLeft(bool $value) : $this
Parameters
$value : bool

Right-to-left true/false

Return values
$this

setSelectedCell()

Selected cell.

public setSelectedCell(string $pCoordinate) : $this
Parameters
$pCoordinate : string

Cell (i.e. A1)

Return values
$this

setSelectedCellByColumnAndRow()

Selected cell by using numeric cell coordinates.

public setSelectedCellByColumnAndRow(int $columnIndex, int $row) : $this
Parameters
$columnIndex : int

Numeric column coordinate of the cell

$row : int

Numeric row coordinate of the cell

Return values
$this

setSelectedCells()

Select a range of cells.

public setSelectedCells(string $pCoordinate) : $this
Parameters
$pCoordinate : string

Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6'

Return values
$this

setSheetState()

Set sheet state.

public setSheetState(string $value) : $this
Parameters
$value : string

Sheet state (visible, hidden, veryHidden)

Return values
$this

setSheetView()

Set sheet view.

public setSheetView(SheetView $pValue) : $this
Parameters
$pValue : SheetView
Return values
$this

setShowGridlines()

Set show gridlines.

public setShowGridlines(bool $pValue) : $this
Parameters
$pValue : bool

Show gridlines (true/false)

Return values
$this

setShowRowColHeaders()

Set show row and column headers.

public setShowRowColHeaders(bool $pValue) : $this
Parameters
$pValue : bool

Show row and column headers (true/false)

Return values
$this

setShowSummaryBelow()

Set show summary below.

public setShowSummaryBelow(bool $pValue) : $this
Parameters
$pValue : bool

Show summary below (true/false)

Return values
$this

setShowSummaryRight()

Set show summary right.

public setShowSummaryRight(bool $pValue) : $this
Parameters
$pValue : bool

Show summary right (true/false)

Return values
$this

setTitle()

Set title.

public setTitle(string $title[, bool $updateFormulaCellReferences = true ][, bool $validate = true ]) : $this
Parameters
$title : string

String containing the dimension of this worksheet

$updateFormulaCellReferences : bool = true

Flag indicating whether cell references in formulae should be updated to reflect the new sheet name. This should be left as the default true, unless you are certain that no formula cells on any worksheet contain references to this worksheet

$validate : bool = true

False to skip validation of new title. WARNING: This should only be set at parse time (by Readers), where titles can be assumed to be valid.

Return values
$this

shrinkRangeToFit()

Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet.

public shrinkRangeToFit(string $range) : string
Parameters
$range : string
Return values
string

Adjusted range value

toArray()

Create array from worksheet.

public toArray([mixed $nullValue = null ][, bool $calculateFormulas = true ][, bool $formatData = true ][, bool $returnCellRef = false ]) : array<string|int, mixed>
Parameters
$nullValue : mixed = null

Value returned in the array entry if a cell doesn't exist

$calculateFormulas : bool = true

Should formulas be calculated?

$formatData : bool = true

Should formatting be applied to cell values?

$returnCellRef : bool = false

False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return values
array<string|int, mixed>

unfreezePane()

Unfreeze Pane.

public unfreezePane() : $this
Return values
$this

unmergeCells()

Remove merge on a cell range.

public unmergeCells(string $pRange) : $this
Parameters
$pRange : string

Cell range (e.g. A1:E1)

Return values
$this

unmergeCellsByColumnAndRow()

Remove merge on a cell range by using numeric cell coordinates.

public unmergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2) : $this
Parameters
$columnIndex1 : int

Numeric column coordinate of the first cell

$row1 : int

Numeric row coordinate of the first cell

$columnIndex2 : int

Numeric column coordinate of the last cell

$row2 : int

Numeric row coordinate of the last cell

Return values
$this

unprotectCells()

Remove protection on a cell range.

public unprotectCells(string $pRange) : $this
Parameters
$pRange : string

Cell (e.g. A1) or cell range (e.g. A1:E1)

Return values
$this

unprotectCellsByColumnAndRow()

Remove protection on a cell range by using numeric cell coordinates.

public unprotectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2) : $this
Parameters
$columnIndex1 : int

Numeric column coordinate of the first cell

$row1 : int

Numeric row coordinate of the first cell

$columnIndex2 : int

Numeric column coordinate of the last cell

$row2 : int

Numeric row coordinate of the last cell

Return values
$this

checkSheetCodeName()

Check sheet code name for valid Excel syntax.

private static checkSheetCodeName(string $pValue) : string
Parameters
$pValue : string

The string to check

Return values
string

The valid string

checkSheetTitle()

Check sheet title for valid Excel syntax.

private static checkSheetTitle(string $pValue) : string
Parameters
$pValue : string

The string to check

Return values
string

The valid string

createNewCell()

Create a new cell at the specified coordinate.

private createNewCell(string $pCoordinate) : Cell
Parameters
$pCoordinate : string

Coordinate of the cell

Return values
Cell

Cell that was created

getCellOrNull()

Get an existing cell at a specific coordinate, or null.

private getCellOrNull(string $coordinate) : null|Cell
Parameters
$coordinate : string

Coordinate of the cell, eg: 'A1'

Return values
null|Cell

Cell that was found or null

getWorksheetAndCoordinate()

Get the correct Worksheet and coordinate from a coordinate that may contains reference to another sheet or a named range.

private getWorksheetAndCoordinate(string $pCoordinate) : array<string|int, mixed>
Parameters
$pCoordinate : string
Return values
array<string|int, mixed>

validateNamedRange()

private validateNamedRange(string $definedName[, bool $returnNullIfInvalid = false ]) : DefinedName|null
Parameters
$definedName : string
$returnNullIfInvalid : bool = false
Return values
DefinedName|null

Search results