\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()
validateNamedRange()
$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_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 : int

Maximum 31 characters allowed for sheet title.

Properties

$invalidCharacters

$invalidCharacters : array

Invalid characters in sheet title.

Type

array

$parent

$parent : \PhpOffice\PhpSpreadsheet\Spreadsheet

Parent spreadsheet.

Type

Spreadsheet

$cellCollection

$cellCollection : \PhpOffice\PhpSpreadsheet\Collection\Cells

Collection of cells.

Type

Cells

$rowDimensions

$rowDimensions : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension[]

Collection of row dimensions.

Type

RowDimension[]

$defaultRowDimension

$defaultRowDimension : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension

Default row dimension.

Type

RowDimension

$columnDimensions

$columnDimensions : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension[]

Collection of column dimensions.

Type

ColumnDimension[]

$defaultColumnDimension

$defaultColumnDimension : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

Default column dimension.

Type

ColumnDimension

$drawingCollection

$drawingCollection : \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing[]

Collection of drawings.

Type

BaseDrawing[]

$chartCollection

$chartCollection : \PhpOffice\PhpSpreadsheet\Chart\Chart[]

Collection of Chart objects.

Type

Chart[]

$title

$title : string

Worksheet title.

Type

string

$sheetState

$sheetState : string

Sheet state.

Type

string

$pageSetup

$pageSetup : \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup

Page setup.

Type

PageSetup

$pageMargins

$pageMargins : \PhpOffice\PhpSpreadsheet\Worksheet\PageMargins

Page margins.

Type

PageMargins

$headerFooter

$headerFooter : \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter

Page header/footer.

Type

HeaderFooter

$sheetView

$sheetView : \PhpOffice\PhpSpreadsheet\Worksheet\SheetView

Sheet view.

Type

SheetView

$protection

$protection : \PhpOffice\PhpSpreadsheet\Worksheet\Protection

Protection.

Type

Protection

$styles

$styles : \PhpOffice\PhpSpreadsheet\Style\Style[]

Collection of styles.

Type

Style[]

$conditionalStylesCollection

$conditionalStylesCollection : array

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

Type

array

$cellCollectionIsSorted

$cellCollectionIsSorted : bool

Is the current cell collection sorted already?

Type

bool

$breaks

$breaks : array

Collection of breaks.

Type

array

$mergeCells

$mergeCells : string[]

Collection of merged cell ranges.

Type

string[]

$protectedCells

$protectedCells : array

Collection of protected cell ranges.

Type

array

$autoFilter

$autoFilter : \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter

Autofilter Range and selection.

Type

AutoFilter

$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 : bool

Show gridlines?

Type

bool

$printGridlines

$printGridlines : bool

Print gridlines?

Type

bool

$showRowColHeaders

$showRowColHeaders : bool

Show row and column headers?

Type

bool

$showSummaryBelow

$showSummaryBelow : bool

Show summary below? (Row/Column outline).

Type

bool

$showSummaryRight

$showSummaryRight : bool

Show summary right? (Row/Column outline).

Type

bool

$comments

$comments : \PhpOffice\PhpSpreadsheet\Comment[]

Collection of comments.

Type

Comment[]

$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 : int

Cached highest row.

Type

int

$rightToLeft

$rightToLeft : bool

Right-to-left?

Type

bool

$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

$tabColor

$tabColor : \PhpOffice\PhpSpreadsheet\Style\Color

Tab color.

Type

Color

$dirty

$dirty : bool

Dirty flag.

Type

bool

$hash

$hash : string

Hash.

Type

string

$codeName

$codeName : string

CodeName.

Type

string

Methods

__construct()

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

Create a new worksheet.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet $parent
string $pTitle

Returns

mixed —

disconnectCells()

disconnectCells() : void

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

__destruct()

__destruct() : mixed

Code to execute when this worksheet is unset().

Returns

mixed —

getCellCollection()

getCellCollection() : \PhpOffice\PhpSpreadsheet\Collection\Cells

Return the cell collection.

Returns

\PhpOffice\PhpSpreadsheet\Collection\Cells —

getInvalidCharacters()

getInvalidCharacters() : array

Get array of invalid characters for sheet title.

Returns

array —

getCoordinates()

getCoordinates(bool  $sorted = true) : string[]

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

Parameters

bool $sorted

Also sort the cell collection?

Returns

string[] —

getRowDimensions()

getRowDimensions() : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension[]

Get collection of row dimensions.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\RowDimension[] —

getDefaultRowDimension()

getDefaultRowDimension() : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension

Get default row dimension.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\RowDimension —

getColumnDimensions()

getColumnDimensions() : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension[]

Get collection of column dimensions.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension[] —

getDefaultColumnDimension()

getDefaultColumnDimension() : \PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension

Get default column dimension.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension —

getDrawingCollection()

getDrawingCollection() : \PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing[]

Get collection of drawings.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing[] —

getChartCollection()

getChartCollection() : \PhpOffice\PhpSpreadsheet\Chart\Chart[]

Get collection of charts.

Returns

\PhpOffice\PhpSpreadsheet\Chart\Chart[] —

addChart()

addChart(\PhpOffice\PhpSpreadsheet\Chart\Chart  $pChart, null|int  $iChartIndex = null) : \PhpOffice\PhpSpreadsheet\Chart\Chart

Add chart.

Parameters

\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart
null|int $iChartIndex

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

Returns

\PhpOffice\PhpSpreadsheet\Chart\Chart —

getChartCount()

getChartCount() : int

Return the count of charts on this worksheet.

Returns

int —

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() : string[]

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

Returns

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 —

refreshColumnDimensions()

refreshColumnDimensions() : $this

Refresh column dimensions.

Returns

$this —

refreshRowDimensions()

refreshRowDimensions() : $this

Refresh row dimensions.

Returns

$this —

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() : $this

Calculate widths for auto-size columns.

Returns

$this —

getParent()

getParent() : \PhpOffice\PhpSpreadsheet\Spreadsheet

Get parent.

Returns

\PhpOffice\PhpSpreadsheet\Spreadsheet —

rebindParent()

rebindParent(\PhpOffice\PhpSpreadsheet\Spreadsheet  $parent) : $this

Re-bind parent.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet $parent

Returns

$this —

getTitle()

getTitle() : string

Get title.

Returns

string —

setTitle()

setTitle(string  $title, bool  $updateFormulaCellReferences = true, bool  $validate = true) : $this

Set title.

Parameters

string $title

String containing the dimension of this worksheet

bool $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

bool $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

$this —

getSheetState()

getSheetState() : string

Get sheet state.

Returns

string —

Sheet state (visible, hidden, veryHidden)

setSheetState()

setSheetState(string  $value) : $this

Set sheet state.

Parameters

string $value

Sheet state (visible, hidden, veryHidden)

Returns

$this —

getPageSetup()

getPageSetup() : \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup

Get page setup.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup —

setPageSetup()

setPageSetup(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup  $pValue) : $this

Set page setup.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup $pValue

Returns

$this —

getPageMargins()

getPageMargins() : \PhpOffice\PhpSpreadsheet\Worksheet\PageMargins

Get page margins.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\PageMargins —

setPageMargins()

setPageMargins(\PhpOffice\PhpSpreadsheet\Worksheet\PageMargins  $pValue) : $this

Set page margins.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\PageMargins $pValue

Returns

$this —

getHeaderFooter()

getHeaderFooter() : \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter

Get page header/footer.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter —

setHeaderFooter()

setHeaderFooter(\PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter  $pValue) : $this

Set page header/footer.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter $pValue

Returns

$this —

getSheetView()

getSheetView() : \PhpOffice\PhpSpreadsheet\Worksheet\SheetView

Get sheet view.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\SheetView —

setSheetView()

setSheetView(\PhpOffice\PhpSpreadsheet\Worksheet\SheetView  $pValue) : $this

Set sheet view.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\SheetView $pValue

Returns

$this —

getProtection()

getProtection() : \PhpOffice\PhpSpreadsheet\Worksheet\Protection

Get Protection.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Protection —

setProtection()

setProtection(\PhpOffice\PhpSpreadsheet\Worksheet\Protection  $pValue) : $this

Set Protection.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Protection $pValue

Returns

$this —

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) : int

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

int —

Highest row number

getHighestDataRow()

getHighestDataRow(string  $column = null) : int

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

int —

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) : $this

Set a cell value.

Parameters

string $pCoordinate

Coordinate of the cell, eg: 'A1'

mixed $pValue

Value of the cell

Returns

$this —

setCellValueByColumnAndRow()

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

Set a cell value by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

mixed $value

Value of the cell

Returns

$this —

setCellValueExplicit()

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

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

$this —

setCellValueExplicitByColumnAndRow()

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

Set a cell value by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

mixed $value

Value of the cell

string $dataType

Explicit data type, see DataType::TYPE_*

Returns

$this —

getCell()

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

Get cell at a specific coordinate.

Parameters

string $pCoordinate

Coordinate of the cell, eg: 'A1'

bool $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

getCellByColumnAndRow()

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

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

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

bool $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) : bool

Does the cell at a specific coordinate exist?

Parameters

string $pCoordinate

Coordinate of the cell eg: 'A1'

Returns

bool —

cellExistsByColumnAndRow()

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

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

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

Returns

bool —

getRowDimension()

getRowDimension(int  $pRow, bool  $create = true) : \PhpOffice\PhpSpreadsheet\Worksheet\RowDimension

Get row dimension at a specific row.

Parameters

int $pRow

Numeric index of the row

bool $create

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\RowDimension —

getColumnDimension()

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

Get column dimension at a specific column.

Parameters

string $pColumn

String index of the column eg: 'A'

bool $create

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension —

getColumnDimensionByColumn()

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

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

Parameters

int $columnIndex

Numeric column coordinate of the cell

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\ColumnDimension —

getStyles()

getStyles() : \PhpOffice\PhpSpreadsheet\Style\Style[]

Get styles.

Returns

\PhpOffice\PhpSpreadsheet\Style\Style[] —

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'

Returns

\PhpOffice\PhpSpreadsheet\Style\Style —

getConditionalStyles()

getConditionalStyles(string  $pCoordinate) : \PhpOffice\PhpSpreadsheet\Style\Conditional[]

Get conditional styles for a cell.

Parameters

string $pCoordinate

eg: 'A1'

Returns

\PhpOffice\PhpSpreadsheet\Style\Conditional[] —

conditionalStylesExists()

conditionalStylesExists(string  $pCoordinate) : bool

Do conditional styles exist for this cell?

Parameters

string $pCoordinate

eg: 'A1'

Returns

bool —

removeConditionalStyles()

removeConditionalStyles(string  $pCoordinate) : $this

Removes conditional styles for a cell.

Parameters

string $pCoordinate

eg: 'A1'

Returns

$this —

getConditionalStylesCollection()

getConditionalStylesCollection() : array

Get collection of conditional styles.

Returns

array —

setConditionalStyles()

setConditionalStyles(string  $pCoordinate,  $pValue) : $this

Set conditional styles.

Parameters

string $pCoordinate

eg: 'A1'

$pValue

Conditional[]

Returns

$this —

getStyleByColumnAndRow()

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

Get style for cell by using numeric cell coordinates.

Parameters

int $columnIndex1

Numeric column coordinate of the cell

int $row1

Numeric row coordinate of the cell

null|int $columnIndex2

Numeric column coordinate of the range cell

null|int $row2

Numeric row coordinate of the range cell

Returns

\PhpOffice\PhpSpreadsheet\Style\Style —

duplicateStyle()

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

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")

Returns

$this —

duplicateConditionalStyle()

duplicateConditionalStyle(\PhpOffice\PhpSpreadsheet\Style\Conditional[]  $pCellStyle, string  $pRange = '') : $this

Duplicate conditional style to a range of cells.

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

Parameters

\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")

Returns

$this —

setBreak()

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

Set break on a cell.

Parameters

string $pCoordinate

Cell coordinate (e.g. A1)

int $pBreak

Break type (type of Worksheet::BREAK_*)

Returns

$this —

setBreakByColumnAndRow()

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

Set break on a cell by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

int $break

Break type (type of Worksheet::BREAK_*)

Returns

$this —

getBreaks()

getBreaks() : array[]

Get breaks.

Returns

array[] —

mergeCells()

mergeCells(string  $pRange) : $this

Set merge on a cell range.

Parameters

string $pRange

Cell range (e.g. A1:E1)

Returns

$this —

mergeCellsByColumnAndRow()

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

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

Parameters

int $columnIndex1

Numeric column coordinate of the first cell

int $row1

Numeric row coordinate of the first cell

int $columnIndex2

Numeric column coordinate of the last cell

int $row2

Numeric row coordinate of the last cell

Returns

$this —

unmergeCells()

unmergeCells(string  $pRange) : $this

Remove merge on a cell range.

Parameters

string $pRange

Cell range (e.g. A1:E1)

Returns

$this —

unmergeCellsByColumnAndRow()

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

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

Parameters

int $columnIndex1

Numeric column coordinate of the first cell

int $row1

Numeric row coordinate of the first cell

int $columnIndex2

Numeric column coordinate of the last cell

int $row2

Numeric row coordinate of the last cell

Returns

$this —

getMergeCells()

getMergeCells() : string[]

Get merge cells array.

Returns

string[] —

setMergeCells()

setMergeCells(string[]  $pValue) : $this

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

Parameters

string[] $pValue

Returns

$this —

protectCells()

protectCells(string  $pRange, string  $pPassword, bool  $pAlreadyHashed = false) : $this

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

bool $pAlreadyHashed

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

Returns

$this —

protectCellsByColumnAndRow()

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

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

Parameters

int $columnIndex1

Numeric column coordinate of the first cell

int $row1

Numeric row coordinate of the first cell

int $columnIndex2

Numeric column coordinate of the last cell

int $row2

Numeric row coordinate of the last cell

string $password

Password to unlock the protection

bool $alreadyHashed

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

Returns

$this —

unprotectCells()

unprotectCells(string  $pRange) : $this

Remove protection on a cell range.

Parameters

string $pRange

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

Returns

$this —

unprotectCellsByColumnAndRow()

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

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

Parameters

int $columnIndex1

Numeric column coordinate of the first cell

int $row1

Numeric row coordinate of the first cell

int $columnIndex2

Numeric column coordinate of the last cell

int $row2

Numeric row coordinate of the last cell

Returns

$this —

getProtectedCells()

getProtectedCells() : array[]

Get protected cells.

Returns

array[] —

getAutoFilter()

getAutoFilter() : \PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter

Get Autofilter.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter —

setAutoFilter()

setAutoFilter(\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter|string  $pValue) : $this

Set AutoFilter.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter|string $pValue

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

Returns

$this —

setAutoFilterByColumnAndRow()

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

Set Autofilter Range by using numeric cell coordinates.

Parameters

int $columnIndex1

Numeric column coordinate of the first cell

int $row1

Numeric row coordinate of the first cell

int $columnIndex2

Numeric column coordinate of the second cell

int $row2

Numeric row coordinate of the second cell

Returns

$this —

removeAutoFilter()

removeAutoFilter() : $this

Remove autofilter.

Returns

$this —

getFreezePane()

getFreezePane() : string

Get Freeze Pane.

Returns

string —

freezePane()

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

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

Returns

$this —

freezePaneByColumnAndRow()

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

Freeze Pane by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

Returns

$this —

unfreezePane()

unfreezePane() : $this

Unfreeze Pane.

Returns

$this —

getTopLeftCell()

getTopLeftCell() : int

Get the default position of the right bottom pane.

Returns

int —

insertNewRowBefore()

insertNewRowBefore(int  $pBefore, int  $pNumRows = 1) : $this

Insert a new row, updating all possible related data.

Parameters

int $pBefore

Insert before this one

int $pNumRows

Number of rows to insert

Returns

$this —

insertNewColumnBefore()

insertNewColumnBefore(string  $pBefore, int  $pNumCols = 1) : $this

Insert a new column, updating all possible related data.

Parameters

string $pBefore

Insert before this one, eg: 'A'

int $pNumCols

Number of columns to insert

Returns

$this —

insertNewColumnBeforeByIndex()

insertNewColumnBeforeByIndex(int  $beforeColumnIndex, int  $pNumCols = 1) : $this

Insert a new column, updating all possible related data.

Parameters

int $beforeColumnIndex

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

int $pNumCols

Number of columns to insert

Returns

$this —

removeRow()

removeRow(int  $pRow, int  $pNumRows = 1) : $this

Delete a row, updating all possible related data.

Parameters

int $pRow

Remove starting with this one

int $pNumRows

Number of rows to remove

Returns

$this —

removeColumn()

removeColumn(string  $pColumn, int  $pNumCols = 1) : $this

Remove a column, updating all possible related data.

Parameters

string $pColumn

Remove starting with this one, eg: 'A'

int $pNumCols

Number of columns to remove

Returns

$this —

removeColumnByIndex()

removeColumnByIndex(int  $columnIndex, int  $numColumns = 1) : $this

Remove a column, updating all possible related data.

Parameters

int $columnIndex

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

int $numColumns

Number of columns to remove

Returns

$this —

getShowGridlines()

getShowGridlines() : bool

Show gridlines?

Returns

bool —

setShowGridlines()

setShowGridlines(bool  $pValue) : $this

Set show gridlines.

Parameters

bool $pValue

Show gridlines (true/false)

Returns

$this —

getPrintGridlines()

getPrintGridlines() : bool

Print gridlines?

Returns

bool —

setPrintGridlines()

setPrintGridlines(bool  $pValue) : $this

Set print gridlines.

Parameters

bool $pValue

Print gridlines (true/false)

Returns

$this —

getShowRowColHeaders()

getShowRowColHeaders() : bool

Show row and column headers?

Returns

bool —

setShowRowColHeaders()

setShowRowColHeaders(bool  $pValue) : $this

Set show row and column headers.

Parameters

bool $pValue

Show row and column headers (true/false)

Returns

$this —

getShowSummaryBelow()

getShowSummaryBelow() : bool

Show summary below? (Row/Column outlining).

Returns

bool —

setShowSummaryBelow()

setShowSummaryBelow(bool  $pValue) : $this

Set show summary below.

Parameters

bool $pValue

Show summary below (true/false)

Returns

$this —

getShowSummaryRight()

getShowSummaryRight() : bool

Show summary right? (Row/Column outlining).

Returns

bool —

setShowSummaryRight()

setShowSummaryRight(bool  $pValue) : $this

Set show summary right.

Parameters

bool $pValue

Show summary right (true/false)

Returns

$this —

getComments()

getComments() : \PhpOffice\PhpSpreadsheet\Comment[]

Get comments.

Returns

\PhpOffice\PhpSpreadsheet\Comment[] —

setComments()

setComments(\PhpOffice\PhpSpreadsheet\Comment[]  $pValue) : $this

Set comments array for the entire sheet.

Parameters

\PhpOffice\PhpSpreadsheet\Comment[] $pValue

Returns

$this —

getComment()

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

Get comment for cell.

Parameters

string $pCellCoordinate

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

Returns

\PhpOffice\PhpSpreadsheet\Comment —

getCommentByColumnAndRow()

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

Get comment for cell by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $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 —

setSelectedCell()

setSelectedCell(string  $pCoordinate) : $this

Selected cell.

Parameters

string $pCoordinate

Cell (i.e. A1)

Returns

$this —

setSelectedCells()

setSelectedCells(string  $pCoordinate) : $this

Select a range of cells.

Parameters

string $pCoordinate

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

Returns

$this —

setSelectedCellByColumnAndRow()

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

Selected cell by using numeric cell coordinates.

Parameters

int $columnIndex

Numeric column coordinate of the cell

int $row

Numeric row coordinate of the cell

Returns

$this —

getRightToLeft()

getRightToLeft() : bool

Get right-to-left.

Returns

bool —

setRightToLeft()

setRightToLeft(bool  $value) : $this

Set right-to-left.

Parameters

bool $value

Right-to-left true/false

Returns

$this —

fromArray()

fromArray(array  $source, mixed  $nullValue = null, string  $startCell = 'A1', bool  $strictNullComparison = false) : $this

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

bool $strictNullComparison

Apply strict comparison when testing for null values in the array

Returns

$this —

rangeToArray()

rangeToArray(string  $pRange, mixed  $nullValue = null, bool  $calculateFormulas = true, bool  $formatData = true, bool  $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

bool $calculateFormulas

Should formulas be calculated?

bool $formatData

Should formatting be applied to cell values?

bool $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  $definedName, mixed  $nullValue = null, bool  $calculateFormulas = true, bool  $formatData = true, bool  $returnCellRef = false) : array

Create array from a range of cells.

Parameters

string $definedName

The Named Range that should be returned

mixed $nullValue

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

bool $calculateFormulas

Should formulas be calculated?

bool $formatData

Should formatting be applied to cell values?

bool $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 —

toArray()

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

Create array from worksheet.

Parameters

mixed $nullValue

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

bool $calculateFormulas

Should formulas be calculated?

bool $formatData

Should formatting be applied to cell values?

bool $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(int  $startRow = 1, int  $endRow = null) : \PhpOffice\PhpSpreadsheet\Worksheet\RowIterator

Get row iterator.

Parameters

int $startRow

The row number at which to start iterating

int $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 —

garbageCollect()

garbageCollect() : $this

Run PhpSpreadsheet garbage collector.

Returns

$this —

getHashCode()

getHashCode() : string

Get hash code.

Returns

string —

Hash code

extractSheetTitle()

extractSheetTitle(string  $pRange, bool  $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

bool $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 —

setHyperlink()

setHyperlink(string  $pCellCoordinate, ?\PhpOffice\PhpSpreadsheet\Cell\Hyperlink  $pHyperlink = null) : $this

Set hyperlink.

Parameters

string $pCellCoordinate

Cell coordinate to insert hyperlink, eg: 'A1'

?\PhpOffice\PhpSpreadsheet\Cell\Hyperlink $pHyperlink

Returns

$this —

hyperlinkExists()

hyperlinkExists(string  $pCoordinate) : bool

Hyperlink at a specific coordinate exists?

Parameters

string $pCoordinate

eg: 'A1'

Returns

bool —

getHyperlinkCollection()

getHyperlinkCollection() : \PhpOffice\PhpSpreadsheet\Cell\Hyperlink[]

Get collection of hyperlinks.

Returns

\PhpOffice\PhpSpreadsheet\Cell\Hyperlink[] —

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 —

setDataValidation()

setDataValidation(string  $pCellCoordinate, ?\PhpOffice\PhpSpreadsheet\Cell\DataValidation  $pDataValidation = null) : $this

Set data validation.

Parameters

string $pCellCoordinate

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

?\PhpOffice\PhpSpreadsheet\Cell\DataValidation $pDataValidation

Returns

$this —

dataValidationExists()

dataValidationExists(string  $pCoordinate) : bool

Data validation at a specific coordinate exists?

Parameters

string $pCoordinate

eg: 'A1'

Returns

bool —

getDataValidationCollection()

getDataValidationCollection() : \PhpOffice\PhpSpreadsheet\Cell\DataValidation[]

Get collection of data validations.

Returns

\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

getTabColor()

getTabColor() : \PhpOffice\PhpSpreadsheet\Style\Color

Get tab color.

Returns

\PhpOffice\PhpSpreadsheet\Style\Color —

resetTabColor()

resetTabColor() : $this

Reset tab color.

Returns

$this —

isTabColorSet()

isTabColorSet() : bool

Tab color set?

Returns

bool —

copy()

copy() : static

Copy worksheet (!= clone!).

Returns

static —

__clone()

__clone() : mixed

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

Returns

mixed —

setCodeName()

setCodeName(string  $pValue, bool  $validate = true) : $this

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)

bool $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

$this —

getCodeName()

getCodeName() : null|string

Return the code name of the sheet.

Returns

null|string —

hasCodeName()

hasCodeName() : bool

Sheet has a code name ?

Returns

bool —

checkSheetCodeName()

checkSheetCodeName(string  $pValue) : string

Check sheet code name for valid Excel syntax.

Parameters

string $pValue

The string to check

Returns

string —

The valid string

checkSheetTitle()

checkSheetTitle(string  $pValue) : string

Check sheet title for valid Excel syntax.

Parameters

string $pValue

The string to check

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

validateNamedRange()

validateNamedRange(string  $definedName, bool  $returnNullIfInvalid = false) : ?\PhpOffice\PhpSpreadsheet\DefinedName

Parameters

string $definedName
bool $returnNullIfInvalid

Returns

?\PhpOffice\PhpSpreadsheet\DefinedName —