Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 3115 lines (90 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Worksheet:: (150 methods):
  __construct()
  disconnectCells()
  __destruct()
  getCellCollection()
  getInvalidCharacters()
  checkSheetCodeName()
  checkSheetTitle()
  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()
  getWorksheetAndCoordinate()
  getCellOrNull()
  getCellByColumnAndRow()
  createNewCell()
  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()
  setTopLeftCell()
  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()
  ensureString()
  pregReplace()
  tryDefinedName()
  setSelectedCells()
  setSelectedCellByColumnAndRow()
  getRightToLeft()
  setRightToLeft()
  fromArray()
  rangeToArray()
  validateNamedRange()
  namedRangeToArray()
  toArray()
  getRowIterator()
  getColumnIterator()
  garbageCollect()
  getHashCode()
  extractSheetTitle()
  getHyperlink()
  setHyperlink()
  hyperlinkExists()
  getHyperlinkCollection()
  getDataValidation()
  setDataValidation()
  dataValidationExists()
  getDataValidationCollection()
  shrinkRangeToFit()
  getTabColor()
  resetTabColor()
  isTabColorSet()
  copy()
  __clone()
  setCodeName()
  getCodeName()
  hasCodeName()


Class: Worksheet  - X-Ref

__construct(?Spreadsheet $parent = null, $title = 'Worksheet')   X-Ref
Create a new worksheet.

param: string $title

disconnectCells()   X-Ref
Disconnect all cells from this Worksheet object,
typically so that the worksheet object can be unset.


__destruct()   X-Ref
Code to execute when this worksheet is unset().


getCellCollection()   X-Ref
Return the cell collection.

return: Cells

getInvalidCharacters()   X-Ref
Get array of invalid characters for sheet title.

return: array

checkSheetCodeName($sheetCodeName)   X-Ref
Check sheet code name for valid Excel syntax.

return: string The valid string
param: string $sheetCodeName The string to check

checkSheetTitle($sheetTitle)   X-Ref
Check sheet title for valid Excel syntax.

return: string The valid string
param: string $sheetTitle The string to check

getCoordinates($sorted = true)   X-Ref
Get a sorted list of all cell coordinates currently held in the collection by row and column.

return: string[]
param: bool $sorted Also sort the cell collection?

getRowDimensions()   X-Ref
Get collection of row dimensions.

return: RowDimension[]

getDefaultRowDimension()   X-Ref
Get default row dimension.

return: RowDimension

getColumnDimensions()   X-Ref
Get collection of column dimensions.

return: ColumnDimension[]

getDefaultColumnDimension()   X-Ref
Get default column dimension.

return: ColumnDimension

getDrawingCollection()   X-Ref
Get collection of drawings.

return: ArrayObject<int, BaseDrawing>

getChartCollection()   X-Ref
Get collection of charts.

return: ArrayObject<int, Chart>

addChart(Chart $chart, $chartIndex = null)   X-Ref
Add chart.

return: Chart
param: null|int $chartIndex Index where chart should go (0,1,..., or null for last)

getChartCount()   X-Ref
Return the count of charts on this worksheet.

return: int The number of charts

getChartByIndex($index)   X-Ref
Get a chart by its index position.

return: Chart|false
param: string $index Chart index position

getChartNames()   X-Ref
Return an array of the names of charts on this worksheet.

return: string[] The names of charts

getChartByName($chartName)   X-Ref
Get a chart by name.

return: Chart|false
param: string $chartName Chart name

refreshColumnDimensions()   X-Ref
Refresh column dimensions.

return: $this

refreshRowDimensions()   X-Ref
Refresh row dimensions.

return: $this

calculateWorksheetDimension()   X-Ref
Calculate worksheet dimension.

return: string String containing the dimension of this worksheet

calculateWorksheetDataDimension()   X-Ref
Calculate worksheet data dimension.

return: string String containing the dimension of this worksheet that actually contain data

calculateColumnWidths()   X-Ref
Calculate widths for auto-size columns.

return: $this

getParent()   X-Ref
Get parent.

return: Spreadsheet

rebindParent(Spreadsheet $parent)   X-Ref
Re-bind parent.

return: $this

getTitle()   X-Ref
Get title.

return: string

setTitle($title, $updateFormulaCellReferences = true, $validate = true)   X-Ref
Set title.

return: $this
param: string $title String containing the dimension of this worksheet
param: bool $updateFormulaCellReferences Flag indicating whether cell references in formulae should
param: bool $validate False to skip validation of new title. WARNING: This should only be set

getSheetState()   X-Ref
Get sheet state.

return: string Sheet state (visible, hidden, veryHidden)

setSheetState($value)   X-Ref
Set sheet state.

return: $this
param: string $value Sheet state (visible, hidden, veryHidden)

getPageSetup()   X-Ref
Get page setup.

return: PageSetup

setPageSetup(PageSetup $pageSetup)   X-Ref
Set page setup.

return: $this

getPageMargins()   X-Ref
Get page margins.

return: PageMargins

setPageMargins(PageMargins $pageMargins)   X-Ref
Set page margins.

return: $this

getHeaderFooter()   X-Ref
Get page header/footer.

return: HeaderFooter

setHeaderFooter(HeaderFooter $headerFooter)   X-Ref
Set page header/footer.

return: $this

getSheetView()   X-Ref
Get sheet view.

return: SheetView

setSheetView(SheetView $sheetView)   X-Ref
Set sheet view.

return: $this

getProtection()   X-Ref
Get Protection.

return: Protection

setProtection(Protection $protection)   X-Ref
Set Protection.

return: $this

getHighestColumn($row = null)   X-Ref
Get highest worksheet column.

return: string Highest column name
param: null|int|string $row Return the data highest column for the specified row,

getHighestDataColumn($row = null)   X-Ref
Get highest worksheet column that contains data.

return: string Highest column name that contains data
param: null|int|string $row Return the highest data column for the specified row,

getHighestRow($column = null)   X-Ref
Get highest worksheet row.

return: int Highest row number
param: null|string $column Return the highest data row for the specified column,

getHighestDataRow($column = null)   X-Ref
Get highest worksheet row that contains data.

return: int Highest row number that contains data
param: null|string $column Return the highest data row for the specified column,

getHighestRowAndColumn()   X-Ref
Get highest worksheet column and highest row that have cell records.

return: array Highest column name and highest row number

setCellValue($coordinate, $value)   X-Ref
Set a cell value.

return: $this
param: string $coordinate Coordinate of the cell, eg: 'A1'
param: mixed $value Value of the cell

setCellValueByColumnAndRow($columnIndex, $row, $value)   X-Ref
Set a cell value by using numeric cell coordinates.

return: $this
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell
param: mixed $value Value of the cell

setCellValueExplicit($coordinate, $value, $dataType)   X-Ref
Set a cell value.

return: $this
param: string $coordinate Coordinate of the cell, eg: 'A1'
param: mixed $value Value of the cell
param: string $dataType Explicit data type, see DataType::TYPE_*

setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $dataType)   X-Ref
Set a cell value by using numeric cell coordinates.

return: $this
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell
param: mixed $value Value of the cell
param: string $dataType Explicit data type, see DataType::TYPE_*

getCell(string $coordinate)   X-Ref
Get cell at a specific coordinate.

return: Cell Cell that was found or created
param: string $coordinate Coordinate of the cell, eg: 'A1'

getWorksheetAndCoordinate(string $coordinate)   X-Ref
Get the correct Worksheet and coordinate from a coordinate that may
contains reference to another sheet or a named range.

return: array{0: Worksheet, 1: string}

getCellOrNull($coordinate)   X-Ref
Get an existing cell at a specific coordinate, or null.

return: null|Cell Cell that was found or null
param: string $coordinate Coordinate of the cell, eg: 'A1'

getCellByColumnAndRow($columnIndex, $row)   X-Ref
Get cell at a specific coordinate by using numeric cell coordinates.

return: Cell Cell that was found/created or null
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell

createNewCell($coordinate)   X-Ref
Create a new cell at the specified coordinate.

return: Cell Cell that was created
param: string $coordinate Coordinate of the cell

cellExists($coordinate)   X-Ref
Does the cell at a specific coordinate exist?

return: bool
param: string $coordinate Coordinate of the cell eg: 'A1'

cellExistsByColumnAndRow($columnIndex, $row)   X-Ref
Cell at a specific coordinate by using numeric cell coordinates exists?

return: bool
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell

getRowDimension(int $row)   X-Ref
Get row dimension at a specific row.

param: int $row Numeric index of the row

getColumnDimension(string $column)   X-Ref
Get column dimension at a specific column.

param: string $column String index of the column eg: 'A'

getColumnDimensionByColumn(int $columnIndex)   X-Ref
Get column dimension at a specific column by using numeric cell coordinates.

param: int $columnIndex Numeric column coordinate of the cell

getStyles()   X-Ref
Get styles.

return: Style[]

getStyle($cellCoordinate)   X-Ref
Get style for cell.

return: Style
param: string $cellCoordinate Cell coordinate (or range) to get style for, eg: 'A1'

getConditionalStyles($coordinate)   X-Ref
Get conditional styles for a cell.

return: Conditional[]
param: string $coordinate eg: 'A1' or 'A1:A3'.

conditionalStylesExists($coordinate)   X-Ref
Do conditional styles exist for this cell?

return: bool
param: string $coordinate eg: 'A1' or 'A1:A3'.

removeConditionalStyles($coordinate)   X-Ref
Removes conditional styles for a cell.

return: $this
param: string $coordinate eg: 'A1'

getConditionalStylesCollection()   X-Ref
Get collection of conditional styles.

return: array

setConditionalStyles($coordinate, $styles)   X-Ref
Set conditional styles.

return: $this
param: string $coordinate eg: 'A1'
param: Conditional[] $styles

getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2 = null, $row2 = null)   X-Ref
Get style for cell by using numeric cell coordinates.

return: Style
param: int $columnIndex1 Numeric column coordinate of the cell
param: int $row1 Numeric row coordinate of the cell
param: null|int $columnIndex2 Numeric column coordinate of the range cell
param: null|int $row2 Numeric row coordinate of the range cell

duplicateStyle(Style $style, $range)   X-Ref
Duplicate cell style to a range of cells.

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

return: $this
param: Style $style Cell style to duplicate
param: string $range Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

duplicateConditionalStyle(array $styles, $range = '')   X-Ref
Duplicate conditional style to a range of cells.

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

return: $this
param: Conditional[] $styles Cell style to duplicate
param: string $range Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

setBreak($coordinate, $break)   X-Ref
Set break on a cell.

return: $this
param: string $coordinate Cell coordinate (e.g. A1)
param: int $break Break type (type of Worksheet::BREAK_*)

setBreakByColumnAndRow($columnIndex, $row, $break)   X-Ref
Set break on a cell by using numeric cell coordinates.

return: $this
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell
param: int $break Break type (type of Worksheet::BREAK_*)

getBreaks()   X-Ref
Get breaks.

return: int[]

mergeCells($range)   X-Ref
Set merge on a cell range.

return: $this
param: string $range Cell range (e.g. A1:E1)

mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)   X-Ref
Set merge on a cell range by using numeric cell coordinates.

return: $this
param: int $columnIndex1 Numeric column coordinate of the first cell
param: int $row1 Numeric row coordinate of the first cell
param: int $columnIndex2 Numeric column coordinate of the last cell
param: int $row2 Numeric row coordinate of the last cell

unmergeCells($range)   X-Ref
Remove merge on a cell range.

return: $this
param: string $range Cell range (e.g. A1:E1)

unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)   X-Ref
Remove merge on a cell range by using numeric cell coordinates.

return: $this
param: int $columnIndex1 Numeric column coordinate of the first cell
param: int $row1 Numeric row coordinate of the first cell
param: int $columnIndex2 Numeric column coordinate of the last cell
param: int $row2 Numeric row coordinate of the last cell

getMergeCells()   X-Ref
Get merge cells array.

return: string[]

setMergeCells(array $mergeCells)   X-Ref
Set merge cells array for the entire sheet. Use instead mergeCells() to merge
a single cell range.

return: $this
param: string[] $mergeCells

protectCells($range, $password, $alreadyHashed = false)   X-Ref
Set protection on a cell range.

return: $this
param: string $range Cell (e.g. A1) or cell range (e.g. A1:E1)
param: string $password Password to unlock the protection
param: bool $alreadyHashed If the password has already been hashed, set this to true

protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $password, $alreadyHashed = false)   X-Ref
Set protection on a cell range by using numeric cell coordinates.

return: $this
param: int $columnIndex1 Numeric column coordinate of the first cell
param: int $row1 Numeric row coordinate of the first cell
param: int $columnIndex2 Numeric column coordinate of the last cell
param: int $row2 Numeric row coordinate of the last cell
param: string $password Password to unlock the protection
param: bool $alreadyHashed If the password has already been hashed, set this to true

unprotectCells($range)   X-Ref
Remove protection on a cell range.

return: $this
param: string $range Cell (e.g. A1) or cell range (e.g. A1:E1)

unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)   X-Ref
Remove protection on a cell range by using numeric cell coordinates.

return: $this
param: int $columnIndex1 Numeric column coordinate of the first cell
param: int $row1 Numeric row coordinate of the first cell
param: int $columnIndex2 Numeric column coordinate of the last cell
param: int $row2 Numeric row coordinate of the last cell

getProtectedCells()   X-Ref
Get protected cells.

return: string[]

getAutoFilter()   X-Ref
Get Autofilter.

return: AutoFilter

setAutoFilter($autoFilterOrRange)   X-Ref
Set AutoFilter.

return: $this
param: AutoFilter|string $autoFilterOrRange

setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)   X-Ref
Set Autofilter Range by using numeric cell coordinates.

return: $this
param: int $columnIndex1 Numeric column coordinate of the first cell
param: int $row1 Numeric row coordinate of the first cell
param: int $columnIndex2 Numeric column coordinate of the second cell
param: int $row2 Numeric row coordinate of the second cell

removeAutoFilter()   X-Ref
Remove autofilter.


getFreezePane()   X-Ref
Get Freeze Pane.

return: null|string

freezePane($cell, $topLeftCell = null)   X-Ref
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)

return: $this
param: null|string $cell Position of the split
param: null|string $topLeftCell default position of the right bottom pane

setTopLeftCell(string $topLeftCell)   X-Ref
No description

freezePaneByColumnAndRow($columnIndex, $row)   X-Ref
Freeze Pane by using numeric cell coordinates.

return: $this
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell

unfreezePane()   X-Ref
Unfreeze Pane.

return: $this

getTopLeftCell()   X-Ref
Get the default position of the right bottom pane.

return: null|string

insertNewRowBefore($before, $numberOfRows = 1)   X-Ref
Insert a new row, updating all possible related data.

return: $this
param: int $before Insert before this one
param: int $numberOfRows Number of rows to insert

insertNewColumnBefore($before, $numberOfColumns = 1)   X-Ref
Insert a new column, updating all possible related data.

return: $this
param: string $before Insert before this one, eg: 'A'
param: int $numberOfColumns Number of columns to insert

insertNewColumnBeforeByIndex($beforeColumnIndex, $numberOfColumns = 1)   X-Ref
Insert a new column, updating all possible related data.

return: $this
param: int $beforeColumnIndex Insert before this one (numeric column coordinate of the cell)
param: int $numberOfColumns Number of columns to insert

removeRow($row, $numberOfRows = 1)   X-Ref
Delete a row, updating all possible related data.

return: $this
param: int $row Remove starting with this one
param: int $numberOfRows Number of rows to remove

removeColumn($column, $numberOfColumns = 1)   X-Ref
Remove a column, updating all possible related data.

return: $this
param: string $column Remove starting with this one, eg: 'A'
param: int $numberOfColumns Number of columns to remove

removeColumnByIndex($columnIndex, $numColumns = 1)   X-Ref
Remove a column, updating all possible related data.

return: $this
param: int $columnIndex Remove starting with this one (numeric column coordinate of the cell)
param: int $numColumns Number of columns to remove

getShowGridlines()   X-Ref
Show gridlines?

return: bool

setShowGridlines($showGridLines)   X-Ref
Set show gridlines.

return: $this
param: bool $showGridLines Show gridlines (true/false)

getPrintGridlines()   X-Ref
Print gridlines?

return: bool

setPrintGridlines($printGridLines)   X-Ref
Set print gridlines.

return: $this
param: bool $printGridLines Print gridlines (true/false)

getShowRowColHeaders()   X-Ref
Show row and column headers?

return: bool

setShowRowColHeaders($showRowColHeaders)   X-Ref
Set show row and column headers.

return: $this
param: bool $showRowColHeaders Show row and column headers (true/false)

getShowSummaryBelow()   X-Ref
Show summary below? (Row/Column outlining).

return: bool

setShowSummaryBelow($showSummaryBelow)   X-Ref
Set show summary below.

return: $this
param: bool $showSummaryBelow Show summary below (true/false)

getShowSummaryRight()   X-Ref
Show summary right? (Row/Column outlining).

return: bool

setShowSummaryRight($showSummaryRight)   X-Ref
Set show summary right.

return: $this
param: bool $showSummaryRight Show summary right (true/false)

getComments()   X-Ref
Get comments.

return: Comment[]

setComments(array $comments)   X-Ref
Set comments array for the entire sheet.

return: $this
param: Comment[] $comments

getComment($cellCoordinate)   X-Ref
Get comment for cell.

return: Comment
param: string $cellCoordinate Cell coordinate to get comment for, eg: 'A1'

getCommentByColumnAndRow($columnIndex, $row)   X-Ref
Get comment for cell by using numeric cell coordinates.

return: Comment
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell

getActiveCell()   X-Ref
Get active cell.

return: string Example: 'A1'

getSelectedCells()   X-Ref
Get selected cells.

return: string

setSelectedCell($coordinate)   X-Ref
Selected cell.

return: $this
param: string $coordinate Cell (i.e. A1)

ensureString($str)   X-Ref
Sigh - Phpstan thinks, correctly, that preg_replace can return null.
But Scrutinizer doesn't. Try to satisfy both.

param: mixed $str

pregReplace(string $pattern, string $replacement, string $subject)   X-Ref
No description

tryDefinedName(string $coordinate)   X-Ref
No description

setSelectedCells($coordinate)   X-Ref
Select a range of cells.

return: $this
param: string $coordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6'

setSelectedCellByColumnAndRow($columnIndex, $row)   X-Ref
Selected cell by using numeric cell coordinates.

return: $this
param: int $columnIndex Numeric column coordinate of the cell
param: int $row Numeric row coordinate of the cell

getRightToLeft()   X-Ref
Get right-to-left.

return: bool

setRightToLeft($value)   X-Ref
Set right-to-left.

return: $this
param: bool $value Right-to-left true/false

fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false)   X-Ref
Fill worksheet from values in array.

return: $this
param: array $source Source array
param: mixed $nullValue Value in source array that stands for blank cell
param: string $startCell Insert array starting from this cell address as the top left coordinate
param: bool $strictNullComparison Apply strict comparison when testing for null values in the array

rangeToArray($range, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)   X-Ref
Create array from a range of cells.

return: array
param: string $range Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
param: mixed $nullValue Value returned in the array entry if a cell doesn't exist
param: bool $calculateFormulas Should formulas be calculated?
param: bool $formatData Should formatting be applied to cell values?
param: bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero

validateNamedRange(string $definedName, bool $returnNullIfInvalid = false)   X-Ref
No description

namedRangeToArray(string $definedName, $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)   X-Ref
Create array from a range of cells.

return: array
param: string $definedName The Named Range that should be returned
param: mixed $nullValue Value returned in the array entry if a cell doesn't exist
param: bool $calculateFormulas Should formulas be calculated?
param: bool $formatData Should formatting be applied to cell values?
param: bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero

toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)   X-Ref
Create array from worksheet.

return: array
param: mixed $nullValue Value returned in the array entry if a cell doesn't exist
param: bool $calculateFormulas Should formulas be calculated?
param: bool $formatData Should formatting be applied to cell values?
param: bool $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero

getRowIterator($startRow = 1, $endRow = null)   X-Ref
Get row iterator.

return: RowIterator
param: int $startRow The row number at which to start iterating
param: int $endRow The row number at which to stop iterating

getColumnIterator($startColumn = 'A', $endColumn = null)   X-Ref
Get column iterator.

return: ColumnIterator
param: string $startColumn The column address at which to start iterating
param: string $endColumn The column address at which to stop iterating

garbageCollect()   X-Ref
Run PhpSpreadsheet garbage collector.

return: $this

getHashCode()   X-Ref
Get hash code.

return: string Hash code

extractSheetTitle($range, $returnRange = false)   X-Ref
Extract worksheet title from range.

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

return: mixed
param: string $range Range to extract title from
param: bool $returnRange Return range? (see example)

getHyperlink($cellCoordinate)   X-Ref
Get hyperlink.

return: Hyperlink
param: string $cellCoordinate Cell coordinate to get hyperlink for, eg: 'A1'

setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null)   X-Ref
Set hyperlink.

return: $this
param: string $cellCoordinate Cell coordinate to insert hyperlink, eg: 'A1'

hyperlinkExists($coordinate)   X-Ref
Hyperlink at a specific coordinate exists?

return: bool
param: string $coordinate eg: 'A1'

getHyperlinkCollection()   X-Ref
Get collection of hyperlinks.

return: Hyperlink[]

getDataValidation($cellCoordinate)   X-Ref
Get data validation.

return: DataValidation
param: string $cellCoordinate Cell coordinate to get data validation for, eg: 'A1'

setDataValidation($cellCoordinate, ?DataValidation $dataValidation = null)   X-Ref
Set data validation.

return: $this
param: string $cellCoordinate Cell coordinate to insert data validation, eg: 'A1'

dataValidationExists($coordinate)   X-Ref
Data validation at a specific coordinate exists?

return: bool
param: string $coordinate eg: 'A1'

getDataValidationCollection()   X-Ref
Get collection of data validations.

return: DataValidation[]

shrinkRangeToFit($range)   X-Ref
Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet.

return: string Adjusted range value
param: string $range

getTabColor()   X-Ref
Get tab color.

return: Color

resetTabColor()   X-Ref
Reset tab color.

return: $this

isTabColorSet()   X-Ref
Tab color set?

return: bool

copy()   X-Ref
Copy worksheet (!= clone!).

return: static

__clone()   X-Ref
Implement PHP __clone to create a deep clone, not just a shallow copy.


setCodeName($codeName, $validate = true)   X-Ref
Define the code name of the sheet.

return: $this
param: string $codeName Same rule as Title minus space not allowed (but, like Excel, change
param: bool $validate False to skip validation of new title. WARNING: This should only be set

getCodeName()   X-Ref
Return the code name of the sheet.

return: null|string

hasCodeName()   X-Ref
Sheet has a code name ?

return: bool