\PhpOffice\PhpSpreadsheet\WorksheetWorksheet

Summary

Methods
Properties
Constants
__construct()
disconnectCells()
__destruct()
getCellCollection()
getInvalidCharacters()
getCoordinates()
getRowDimensions()
getDefaultRowDimension()
getColumnDimensions()
getDefaultColumnDimension()
getDrawingCollection()
getChartCollection()
addChart()
getChartCount()
getChartByIndex()
getChartNames()
getChartByName()
refreshColumnDimensions()
refreshRowDimensions()
calculateWorksheetDimension()
calculateWorksheetDataDimension()
calculateColumnWidths()
getParent()
rebindParent()
getTitle()
setTitle()
getSheetState()
setSheetState()
getPageSetup()
setPageSetup()
getPageMargins()
setPageMargins()
getHeaderFooter()
setHeaderFooter()
getSheetView()
setSheetView()
getProtection()
setProtection()
getHighestColumn()
getHighestDataColumn()
getHighestRow()
getHighestDataRow()
getHighestRowAndColumn()
setCellValue()
setCellValueByColumnAndRow()
setCellValueExplicit()
setCellValueExplicitByColumnAndRow()
getCell()
getCellByColumnAndRow()
cellExists()
cellExistsByColumnAndRow()
getRowDimension()
getColumnDimension()
getColumnDimensionByColumn()
getStyles()
getStyle()
getConditionalStyles()
conditionalStylesExists()
removeConditionalStyles()
getConditionalStylesCollection()
setConditionalStyles()
getStyleByColumnAndRow()
duplicateStyle()
duplicateConditionalStyle()
setBreak()
setBreakByColumnAndRow()
getBreaks()
mergeCells()
mergeCellsByColumnAndRow()
unmergeCells()
unmergeCellsByColumnAndRow()
getMergeCells()
setMergeCells()
protectCells()
protectCellsByColumnAndRow()
unprotectCells()
unprotectCellsByColumnAndRow()
getProtectedCells()
getAutoFilter()
setAutoFilter()
setAutoFilterByColumnAndRow()
removeAutoFilter()
getFreezePane()
freezePane()
freezePaneByColumnAndRow()
unfreezePane()
getTopLeftCell()
insertNewRowBefore()
insertNewColumnBefore()
insertNewColumnBeforeByIndex()
removeRow()
removeColumn()
removeColumnByIndex()
getShowGridlines()
setShowGridlines()
getPrintGridlines()
setPrintGridlines()
getShowRowColHeaders()
setShowRowColHeaders()
getShowSummaryBelow()
setShowSummaryBelow()
getShowSummaryRight()
setShowSummaryRight()
getComments()
setComments()
getComment()
getCommentByColumnAndRow()
getActiveCell()
getSelectedCells()
setSelectedCell()
setSelectedCells()
setSelectedCellByColumnAndRow()
getRightToLeft()
setRightToLeft()
fromArray()
rangeToArray()
namedRangeToArray()
toArray()
getRowIterator()
getColumnIterator()
garbageCollect()
getHashCode()
extractSheetTitle()
getHyperlink()
setHyperlink()
hyperlinkExists()
getHyperlinkCollection()
getDataValidation()
setDataValidation()
dataValidationExists()
getDataValidationCollection()
shrinkRangeToFit()
getTabColor()
resetTabColor()
isTabColorSet()
copy()
__clone()
setCodeName()
getCodeName()
hasCodeName()
No public properties found
BREAK_NONE
BREAK_ROW
BREAK_COLUMN
SHEETSTATE_VISIBLE
SHEETSTATE_HIDDEN
SHEETSTATE_VERYHIDDEN
SHEET_TITLE_MAXIMUM_LENGTH
No protected methods found
No protected properties found
N/A
checkSheetCodeName()
checkSheetTitle()
createNewCell()
$invalidCharacters
$parent
$cellCollection
$rowDimensions
$defaultRowDimension
$columnDimensions
$defaultColumnDimension
$drawingCollection
$chartCollection
$title
$sheetState
$pageSetup
$pageMargins
$headerFooter
$sheetView
$protection
$styles
$conditionalStylesCollection
$cellCollectionIsSorted
$breaks
$mergeCells
$protectedCells
$autoFilter
$freezePane
$topLeftCell
$showGridlines
$printGridlines
$showRowColHeaders
$showSummaryBelow
$showSummaryRight
$comments
$activeCell
$selectedCells
$cachedHighestColumn
$cachedHighestRow
$rightToLeft
$hyperlinkCollection
$dataValidationCollection
$tabColor
$dirty
$hash
$codeName
N/A

Constants

BREAK_NONE

BREAK_NONE = 0

BREAK_ROW

BREAK_ROW = 1

BREAK_COLUMN

BREAK_COLUMN = 2

SHEETSTATE_VISIBLE

SHEETSTATE_VISIBLE = 'visible'

SHEETSTATE_HIDDEN

SHEETSTATE_HIDDEN = 'hidden'

SHEETSTATE_VERYHIDDEN

SHEETSTATE_VERYHIDDEN = 'veryHidden'

SHEET_TITLE_MAXIMUM_LENGTH

SHEET_TITLE_MAXIMUM_LENGTH = 31 : integer

Maximum 31 characters allowed for sheet title.

Properties

$invalidCharacters

$invalidCharacters : array

Invalid characters in sheet title.

Type

array

$title

$title : string

Worksheet title.

Type

string

$sheetState

$sheetState : string

Sheet state.

Type

string

$conditionalStylesCollection

$conditionalStylesCollection : array

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

Type

array

$cellCollectionIsSorted

$cellCollectionIsSorted : boolean

Is the current cell collection sorted already?

Type

boolean

$breaks

$breaks : array

Collection of breaks.

Type

array

$mergeCells

$mergeCells : array

Collection of merged cell ranges.

Type

array

$protectedCells

$protectedCells : array

Collection of protected cell ranges.

Type

array

$freezePane

$freezePane : null|string

Freeze pane.

Type

null|string

$topLeftCell

$topLeftCell : null|string

Default position of the right bottom pane.

Type

null|string

$showGridlines

$showGridlines : boolean

Show gridlines?

Type

boolean

$printGridlines

$printGridlines : boolean

Print gridlines?

Type

boolean

$showRowColHeaders

$showRowColHeaders : boolean

Show row and column headers?

Type

boolean

$showSummaryBelow

$showSummaryBelow : boolean

Show summary below? (Row/Column outline).

Type

boolean

$showSummaryRight

$showSummaryRight : boolean

Show summary right? (Row/Column outline).

Type

boolean

$activeCell

$activeCell : string

Active cell. (Only one!).

Type

string

$selectedCells

$selectedCells : string

Selected cells.

Type

string

$cachedHighestColumn

$cachedHighestColumn : string

Cached highest column.

Type

string

$cachedHighestRow

$cachedHighestRow : integer

Cached highest row.

Type

integer

$rightToLeft

$rightToLeft : boolean

Right-to-left?

Type

boolean

$hyperlinkCollection

$hyperlinkCollection : array

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

Type

array

$dataValidationCollection

$dataValidationCollection : array

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

Type

array

$dirty

$dirty : boolean

Dirty flag.

Type

boolean

$hash

$hash : string

Hash.

Type

string

$codeName

$codeName : string

CodeName.

Type

string

Methods

__construct()

__construct(\PhpOffice\PhpSpreadsheet\Spreadsheet  $parent = null, string  $pTitle = 'Worksheet') 

Create a new worksheet.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet $parent
string $pTitle

disconnectCells()

disconnectCells() 

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

__destruct()

__destruct() 

Code to execute when this worksheet is unset().

getInvalidCharacters()

getInvalidCharacters() : array

Get array of invalid characters for sheet title.

Returns

array

getCoordinates()

getCoordinates(boolean  $sorted = true) : array<mixed,string>

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

Parameters

boolean $sorted

Also sort the cell collection?

Returns

array<mixed,string>

getChartCount()

getChartCount() : integer

Return the count of charts on this worksheet.

Returns

integer —

The number of charts

getChartByIndex()

getChartByIndex(string  $index) : \PhpOffice\PhpSpreadsheet\Chart\Chart|false

Get a chart by its index position.

Parameters

string $index

Chart index position

Returns

\PhpOffice\PhpSpreadsheet\Chart\Chart|false

getChartNames()

getChartNames() : array<mixed,string>

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

Returns

array<mixed,string> —

The names of charts

getChartByName()

getChartByName(string  $chartName) : \PhpOffice\PhpSpreadsheet\Chart\Chart|false

Get a chart by name.

Parameters

string $chartName

Chart name

Returns

\PhpOffice\PhpSpreadsheet\Chart\Chart|false

calculateWorksheetDimension()

calculateWorksheetDimension() : string

Calculate worksheet dimension.

Returns

string —

String containing the dimension of this worksheet

calculateWorksheetDataDimension()

calculateWorksheetDataDimension() : string

Calculate worksheet data dimension.

Returns

string —

String containing the dimension of this worksheet that actually contain data

calculateColumnWidths()

calculateColumnWidths() : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

Calculate widths for auto-size columns.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

getTitle()

getTitle() : string

Get title.

Returns

string

setTitle()

setTitle(string  $pValue, boolean  $updateFormulaCellReferences = true, boolean  $validate = true) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set title.

Parameters

string $pValue

String containing the dimension of this worksheet

boolean $updateFormulaCellReferences

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

boolean $validate

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.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getSheetState()

getSheetState() : string

Get sheet state.

Returns

string —

Sheet state (visible, hidden, veryHidden)

setSheetState()

setSheetState(string  $value) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set sheet state.

Parameters

string $value

Sheet state (visible, hidden, veryHidden)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getHighestColumn()

getHighestColumn(string  $row = null) : string

Get highest worksheet column.

Parameters

string $row

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

Returns

string —

Highest column name

getHighestDataColumn()

getHighestDataColumn(string  $row = null) : string

Get highest worksheet column that contains data.

Parameters

string $row

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

Returns

string —

Highest column name that contains data

getHighestRow()

getHighestRow(string  $column = null) : integer

Get highest worksheet row.

Parameters

string $column

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

Returns

integer —

Highest row number

getHighestDataRow()

getHighestDataRow(string  $column = null) : string

Get highest worksheet row that contains data.

Parameters

string $column

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

Returns

string —

Highest row number that contains data

getHighestRowAndColumn()

getHighestRowAndColumn() : array

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

Returns

array —

Highest column name and highest row number

setCellValue()

setCellValue(string  $pCoordinate, mixed  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set a cell value.

Parameters

string $pCoordinate

Coordinate of the cell, eg: 'A1'

mixed $pValue

Value of the cell

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setCellValueByColumnAndRow()

setCellValueByColumnAndRow(integer  $columnIndex, integer  $row, mixed  $value) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set a cell value by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

mixed $value

Value of the cell

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setCellValueExplicit()

setCellValueExplicit(string  $pCoordinate, mixed  $pValue, string  $pDataType) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set a cell value.

Parameters

string $pCoordinate

Coordinate of the cell, eg: 'A1'

mixed $pValue

Value of the cell

string $pDataType

Explicit data type, see DataType::TYPE_*

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setCellValueExplicitByColumnAndRow()

setCellValueExplicitByColumnAndRow(integer  $columnIndex, integer  $row, mixed  $value, string  $dataType) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set a cell value by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

mixed $value

Value of the cell

string $dataType

Explicit data type, see DataType::TYPE_*

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getCell()

getCell(string  $pCoordinate, boolean  $createIfNotExists = true) : null|\PhpOffice\PhpSpreadsheet\Cell\Cell

Get cell at a specific coordinate.

Parameters

string $pCoordinate

Coordinate of the cell, eg: 'A1'

boolean $createIfNotExists

Flag indicating whether a new cell should be created if it doesn't already exist, or a null should be returned instead

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

null|\PhpOffice\PhpSpreadsheet\Cell\Cell

Cell that was found/created or null

getCellByColumnAndRow()

getCellByColumnAndRow(integer  $columnIndex, integer  $row, boolean  $createIfNotExists = true) : null|\PhpOffice\PhpSpreadsheet\Cell\Cell

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

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

boolean $createIfNotExists

Flag indicating whether a new cell should be created if it doesn't already exist, or a null should be returned instead

Returns

null|\PhpOffice\PhpSpreadsheet\Cell\Cell

Cell that was found/created or null

cellExists()

cellExists(string  $pCoordinate) : boolean

Does the cell at a specific coordinate exist?

Parameters

string $pCoordinate

Coordinate of the cell eg: 'A1'

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

boolean

cellExistsByColumnAndRow()

cellExistsByColumnAndRow(integer  $columnIndex, integer  $row) : boolean

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

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

Returns

boolean

getRowDimension()

getRowDimension(integer  $pRow, boolean  $create = true) : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension

Get row dimension at a specific row.

Parameters

integer $pRow

Numeric index of the row

boolean $create

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\RowDimension

getColumnDimension()

getColumnDimension(string  $pColumn, boolean  $create = true) : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

Get column dimension at a specific column.

Parameters

string $pColumn

String index of the column eg: 'A'

boolean $create

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

getColumnDimensionByColumn()

getColumnDimensionByColumn(integer  $columnIndex) : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

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

Parameters

integer $columnIndex

Numeric column coordinate of the cell

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

getStyle()

getStyle(string  $pCellCoordinate) : \PhpOffice\PhpSpreadsheet\Style\Style

Get style for cell.

Parameters

string $pCellCoordinate

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

getConditionalStyles()

getConditionalStyles(string  $pCoordinate) : array<mixed,\PhpOffice\PhpSpreadsheet\Style\Conditional>

Get conditional styles for a cell.

Parameters

string $pCoordinate

eg: 'A1'

Returns

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Conditional>

conditionalStylesExists()

conditionalStylesExists(string  $pCoordinate) : boolean

Do conditional styles exist for this cell?

Parameters

string $pCoordinate

eg: 'A1'

Returns

boolean

removeConditionalStyles()

removeConditionalStyles(string  $pCoordinate) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Removes conditional styles for a cell.

Parameters

string $pCoordinate

eg: 'A1'

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getConditionalStylesCollection()

getConditionalStylesCollection() : array

Get collection of conditional styles.

Returns

array

setConditionalStyles()

setConditionalStyles(string  $pCoordinate,   $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set conditional styles.

Parameters

string $pCoordinate

eg: 'A1'

$pValue

Conditional[]

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getStyleByColumnAndRow()

getStyleByColumnAndRow(integer  $columnIndex1, integer  $row1, null|integer  $columnIndex2 = null, null|integer  $row2 = null) : \PhpOffice\PhpSpreadsheet\Style\Style

Get style for cell by using numeric cell coordinates.

Parameters

integer $columnIndex1

Numeric column coordinate of the cell

integer $row1

Numeric row coordinate of the cell

null|integer $columnIndex2

Numeric column coordinate of the range cell

null|integer $row2

Numeric row coordinate of the range cell

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

duplicateStyle()

duplicateStyle(\PhpOffice\PhpSpreadsheet\Style\Style  $pCellStyle, string  $pRange) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Duplicate cell style to a range of cells.

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

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $pCellStyle

Cell style to duplicate

string $pRange

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

duplicateConditionalStyle()

duplicateConditionalStyle(array<mixed,\PhpOffice\PhpSpreadsheet\Style\Conditional>  $pCellStyle, string  $pRange = '') : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Duplicate conditional style to a range of cells.

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

Parameters

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Conditional> $pCellStyle

Cell style to duplicate

string $pRange

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setBreak()

setBreak(string  $pCoordinate, integer  $pBreak) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set break on a cell.

Parameters

string $pCoordinate

Cell coordinate (e.g. A1)

integer $pBreak

Break type (type of Worksheet::BREAK_*)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setBreakByColumnAndRow()

setBreakByColumnAndRow(integer  $columnIndex, integer  $row, integer  $break) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set break on a cell by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

integer $break

Break type (type of Worksheet::BREAK_*)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getBreaks()

getBreaks() : array<mixed,array>

Get breaks.

Returns

array<mixed,array>

mergeCells()

mergeCells(string  $pRange) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set merge on a cell range.

Parameters

string $pRange

Cell range (e.g. A1:E1)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

mergeCellsByColumnAndRow()

mergeCellsByColumnAndRow(integer  $columnIndex1, integer  $row1, integer  $columnIndex2, integer  $row2) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

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

Parameters

integer $columnIndex1

Numeric column coordinate of the first cell

integer $row1

Numeric row coordinate of the first cell

integer $columnIndex2

Numeric column coordinate of the last cell

integer $row2

Numeric row coordinate of the last cell

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

unmergeCells()

unmergeCells(string  $pRange) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Remove merge on a cell range.

Parameters

string $pRange

Cell range (e.g. A1:E1)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

unmergeCellsByColumnAndRow()

unmergeCellsByColumnAndRow(integer  $columnIndex1, integer  $row1, integer  $columnIndex2, integer  $row2) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

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

Parameters

integer $columnIndex1

Numeric column coordinate of the first cell

integer $row1

Numeric row coordinate of the first cell

integer $columnIndex2

Numeric column coordinate of the last cell

integer $row2

Numeric row coordinate of the last cell

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getMergeCells()

getMergeCells() : array<mixed,array>

Get merge cells array.

Returns

array<mixed,array>

setMergeCells()

setMergeCells(array  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

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

Parameters

array $pValue

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

protectCells()

protectCells(string  $pRange, string  $pPassword, boolean  $pAlreadyHashed = false) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set protection on a cell range.

Parameters

string $pRange

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

string $pPassword

Password to unlock the protection

boolean $pAlreadyHashed

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

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

protectCellsByColumnAndRow()

protectCellsByColumnAndRow(integer  $columnIndex1, integer  $row1, integer  $columnIndex2, integer  $row2, string  $password, boolean  $alreadyHashed = false) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

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

Parameters

integer $columnIndex1

Numeric column coordinate of the first cell

integer $row1

Numeric row coordinate of the first cell

integer $columnIndex2

Numeric column coordinate of the last cell

integer $row2

Numeric row coordinate of the last cell

string $password

Password to unlock the protection

boolean $alreadyHashed

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

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

unprotectCells()

unprotectCells(string  $pRange) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Remove protection on a cell range.

Parameters

string $pRange

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

unprotectCellsByColumnAndRow()

unprotectCellsByColumnAndRow(integer  $columnIndex1, integer  $row1, integer  $columnIndex2, integer  $row2) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

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

Parameters

integer $columnIndex1

Numeric column coordinate of the first cell

integer $row1

Numeric row coordinate of the first cell

integer $columnIndex2

Numeric column coordinate of the last cell

integer $row2

Numeric row coordinate of the last cell

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getProtectedCells()

getProtectedCells() : array<mixed,array>

Get protected cells.

Returns

array<mixed,array>

setAutoFilterByColumnAndRow()

setAutoFilterByColumnAndRow(integer  $columnIndex1, integer  $row1, integer  $columnIndex2, integer  $row2) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set Autofilter Range by using numeric cell coordinates.

Parameters

integer $columnIndex1

Numeric column coordinate of the first cell

integer $row1

Numeric row coordinate of the first cell

integer $columnIndex2

Numeric column coordinate of the second cell

integer $row2

Numeric row coordinate of the second cell

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getFreezePane()

getFreezePane() : string

Get Freeze Pane.

Returns

string

freezePane()

freezePane(null|string  $cell, null|string  $topLeftCell = null) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Freeze Pane.

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

null|string $cell

Position of the split

null|string $topLeftCell

default position of the right bottom pane

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

freezePaneByColumnAndRow()

freezePaneByColumnAndRow(integer  $columnIndex, integer  $row) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Freeze Pane by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getTopLeftCell()

getTopLeftCell() : integer

Get the default position of the right bottom pane.

Returns

integer

insertNewRowBefore()

insertNewRowBefore(integer  $pBefore, integer  $pNumRows = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Insert a new row, updating all possible related data.

Parameters

integer $pBefore

Insert before this one

integer $pNumRows

Number of rows to insert

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

insertNewColumnBefore()

insertNewColumnBefore(integer  $pBefore, integer  $pNumCols = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Insert a new column, updating all possible related data.

Parameters

integer $pBefore

Insert before this one, eg: 'A'

integer $pNumCols

Number of columns to insert

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

insertNewColumnBeforeByIndex()

insertNewColumnBeforeByIndex(integer  $beforeColumnIndex, integer  $pNumCols = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Insert a new column, updating all possible related data.

Parameters

integer $beforeColumnIndex

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

integer $pNumCols

Number of columns to insert

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

removeRow()

removeRow(integer  $pRow, integer  $pNumRows = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Delete a row, updating all possible related data.

Parameters

integer $pRow

Remove starting with this one

integer $pNumRows

Number of rows to remove

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

removeColumn()

removeColumn(string  $pColumn, integer  $pNumCols = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Remove a column, updating all possible related data.

Parameters

string $pColumn

Remove starting with this one, eg: 'A'

integer $pNumCols

Number of columns to remove

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

removeColumnByIndex()

removeColumnByIndex(integer  $columnIndex, integer  $numColumns = 1) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Remove a column, updating all possible related data.

Parameters

integer $columnIndex

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

integer $numColumns

Number of columns to remove

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getShowGridlines()

getShowGridlines() : boolean

Show gridlines?

Returns

boolean

setShowGridlines()

setShowGridlines(boolean  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set show gridlines.

Parameters

boolean $pValue

Show gridlines (true/false)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getPrintGridlines()

getPrintGridlines() : boolean

Print gridlines?

Returns

boolean

setPrintGridlines()

setPrintGridlines(boolean  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set print gridlines.

Parameters

boolean $pValue

Print gridlines (true/false)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getShowRowColHeaders()

getShowRowColHeaders() : boolean

Show row and column headers?

Returns

boolean

setShowRowColHeaders()

setShowRowColHeaders(boolean  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set show row and column headers.

Parameters

boolean $pValue

Show row and column headers (true/false)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getShowSummaryBelow()

getShowSummaryBelow() : boolean

Show summary below? (Row/Column outlining).

Returns

boolean

setShowSummaryBelow()

setShowSummaryBelow(boolean  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set show summary below.

Parameters

boolean $pValue

Show summary below (true/false)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getShowSummaryRight()

getShowSummaryRight() : boolean

Show summary right? (Row/Column outlining).

Returns

boolean

setShowSummaryRight()

setShowSummaryRight(boolean  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set show summary right.

Parameters

boolean $pValue

Show summary right (true/false)

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getComment()

getComment(string  $pCellCoordinate) : \PhpOffice\PhpSpreadsheet\Comment

Get comment for cell.

Parameters

string $pCellCoordinate

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Comment

getCommentByColumnAndRow()

getCommentByColumnAndRow(integer  $columnIndex, integer  $row) : \PhpOffice\PhpSpreadsheet\Comment

Get comment for cell by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

Returns

\PhpOffice\PhpSpreadsheet\Comment

getActiveCell()

getActiveCell() : string

Get active cell.

Returns

string —

Example: 'A1'

getSelectedCells()

getSelectedCells() : string

Get selected cells.

Returns

string

setSelectedCells()

setSelectedCells(string  $pCoordinate) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Select a range of cells.

Parameters

string $pCoordinate

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

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setSelectedCellByColumnAndRow()

setSelectedCellByColumnAndRow(integer  $columnIndex, integer  $row) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Selected cell by using numeric cell coordinates.

Parameters

integer $columnIndex

Numeric column coordinate of the cell

integer $row

Numeric row coordinate of the cell

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getRightToLeft()

getRightToLeft() : boolean

Get right-to-left.

Returns

boolean

fromArray()

fromArray(array  $source, mixed  $nullValue = null, string  $startCell = 'A1', boolean  $strictNullComparison = false) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Fill worksheet from values in array.

Parameters

array $source

Source array

mixed $nullValue

Value in source array that stands for blank cell

string $startCell

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

boolean $strictNullComparison

Apply strict comparison when testing for null values in the array

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

rangeToArray()

rangeToArray(string  $pRange, mixed  $nullValue = null, boolean  $calculateFormulas = true, boolean  $formatData = true, boolean  $returnCellRef = false) : array

Create array from a range of cells.

Parameters

string $pRange

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

mixed $nullValue

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

boolean $calculateFormulas

Should formulas be calculated?

boolean $formatData

Should formatting be applied to cell values?

boolean $returnCellRef

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

Returns

array

namedRangeToArray()

namedRangeToArray(string  $pNamedRange, mixed  $nullValue = null, boolean  $calculateFormulas = true, boolean  $formatData = true, boolean  $returnCellRef = false) : array

Create array from a range of cells.

Parameters

string $pNamedRange

Name of the Named Range

mixed $nullValue

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

boolean $calculateFormulas

Should formulas be calculated?

boolean $formatData

Should formatting be applied to cell values?

boolean $returnCellRef

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

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

array

toArray()

toArray(mixed  $nullValue = null, boolean  $calculateFormulas = true, boolean  $formatData = true, boolean  $returnCellRef = false) : array

Create array from worksheet.

Parameters

mixed $nullValue

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

boolean $calculateFormulas

Should formulas be calculated?

boolean $formatData

Should formatting be applied to cell values?

boolean $returnCellRef

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

Returns

array

getRowIterator()

getRowIterator(integer  $startRow = 1, integer  $endRow = null) : \PhpOffice\PhpSpreadsheet\Worksheet\RowIterator

Get row iterator.

Parameters

integer $startRow

The row number at which to start iterating

integer $endRow

The row number at which to stop iterating

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\RowIterator

getColumnIterator()

getColumnIterator(string  $startColumn = 'A', string  $endColumn = null) : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator

Get column iterator.

Parameters

string $startColumn

The column address at which to start iterating

string $endColumn

The column address at which to stop iterating

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnIterator

getHashCode()

getHashCode() : string

Get hash code.

Returns

string —

Hash code

extractSheetTitle()

extractSheetTitle(string  $pRange, boolean  $returnRange = false) : mixed

Extract worksheet title from range.

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

Parameters

string $pRange

Range to extract title from

boolean $returnRange

Return range? (see example)

Returns

mixed

getHyperlink()

getHyperlink(string  $pCellCoordinate) : \PhpOffice\PhpSpreadsheet\Cell\Hyperlink

Get hyperlink.

Parameters

string $pCellCoordinate

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

Returns

\PhpOffice\PhpSpreadsheet\Cell\Hyperlink

hyperlinkExists()

hyperlinkExists(string  $pCoordinate) : boolean

Hyperlink at a specific coordinate exists?

Parameters

string $pCoordinate

eg: 'A1'

Returns

boolean

getDataValidation()

getDataValidation(string  $pCellCoordinate) : \PhpOffice\PhpSpreadsheet\Cell\DataValidation

Get data validation.

Parameters

string $pCellCoordinate

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

Returns

\PhpOffice\PhpSpreadsheet\Cell\DataValidation

dataValidationExists()

dataValidationExists(string  $pCoordinate) : boolean

Data validation at a specific coordinate exists?

Parameters

string $pCoordinate

eg: 'A1'

Returns

boolean

getDataValidationCollection()

getDataValidationCollection() : array<mixed,\PhpOffice\PhpSpreadsheet\Cell\DataValidation>

Get collection of data validations.

Returns

array<mixed,\PhpOffice\PhpSpreadsheet\Cell\DataValidation>

shrinkRangeToFit()

shrinkRangeToFit(string  $range) : string

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

Parameters

string $range

Returns

string —

Adjusted range value

isTabColorSet()

isTabColorSet() : boolean

Tab color set?

Returns

boolean

__clone()

__clone() 

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

setCodeName()

setCodeName(string  $pValue, boolean  $validate = true) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Define the code name of the sheet.

Parameters

string $pValue

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

boolean $validate

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.

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getCodeName()

getCodeName() : null|string

Return the code name of the sheet.

Returns

null|string

hasCodeName()

hasCodeName() : boolean

Sheet has a code name ?

Returns

boolean

checkSheetCodeName()

checkSheetCodeName(string  $pValue) : string

Check sheet code name for valid Excel syntax.

Parameters

string $pValue

The string to check

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

string —

The valid string

checkSheetTitle()

checkSheetTitle(string  $pValue) : string

Check sheet title for valid Excel syntax.

Parameters

string $pValue

The string to check

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

string —

The valid string

createNewCell()

createNewCell(string  $pCoordinate) : \PhpOffice\PhpSpreadsheet\Cell\Cell

Create a new cell at the specified coordinate.

Parameters

string $pCoordinate

Coordinate of the cell

Returns

\PhpOffice\PhpSpreadsheet\Cell\Cell

Cell that was created