Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

(no description)

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

Defines 1 class

Worksheet:: (162 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()
  rowDimensionExists()
  getColumnDimension()
  getColumnDimensionByColumn()
  getStyles()
  getStyle()
  getStyleByColumnAndRow()
  getConditionalStyles()
  getConditionalRange()
  conditionalStylesExists()
  removeConditionalStyles()
  getConditionalStylesCollection()
  setConditionalStyles()
  duplicateStyle()
  duplicateConditionalStyle()
  setBreak()
  setBreakByColumnAndRow()
  getBreaks()
  mergeCells()
  clearMergeCellsByColumn()
  clearMergeCellsByRow()
  mergeCellBehaviour()
  mergeCellsByColumnAndRow()
  unmergeCells()
  unmergeCellsByColumnAndRow()
  getMergeCells()
  setMergeCells()
  protectCells()
  protectCellsByColumnAndRow()
  unprotectCells()
  unprotectCellsByColumnAndRow()
  getProtectedCells()
  getAutoFilter()
  setAutoFilter()
  setAutoFilterByColumnAndRow()
  removeAutoFilter()
  getTableCollection()
  addTable()
  removeTableByName()
  removeTableCollection()
  getFreezePane()
  freezePane()
  setTopLeftCell()
  freezePaneByColumnAndRow()
  unfreezePane()
  getTopLeftCell()
  insertNewRowBefore()
  insertNewColumnBefore()
  insertNewColumnBeforeByIndex()
  removeRow()
  removeRowDimensions()
  removeColumn()
  removeColumnDimensions()
  removeColumnByIndex()
  getShowGridlines()
  setShowGridlines()
  getPrintGridlines()
  setPrintGridlines()
  getShowRowColHeaders()
  setShowRowColHeaders()
  getShowSummaryBelow()
  setShowSummaryBelow()
  getShowSummaryRight()
  setShowSummaryRight()
  getComments()
  setComments()
  removeComment()
  getComment()
  getCommentByColumnAndRow()
  getActiveCell()
  getSelectedCells()
  setSelectedCell()
  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()
  isEmptyRow()
  isEmptyColumn()
  __clone()
  setCodeName()
  getCodeName()
  hasCodeName()
  nameRequiresQuotes()


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.

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

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

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

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

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

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.

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

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.

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

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.

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

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.

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

getSheetState()   X-Ref
Get sheet state.

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

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

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

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.

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

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

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

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

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

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

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

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.

param: array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';
param: mixed $value Value for the cell
return: $this

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

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

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

param: array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';
param: mixed $value Value of the cell
param: string $dataType Explicit data type, see DataType::TYPE_*
return: $this

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

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_*
return: $this

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

param: array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';
return: Cell Cell that was found or created

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.

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

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

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

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

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

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

param: array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';

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

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

rowDimensionExists(int $row)   X-Ref
No description

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.

param: AddressRange|array<int>|CellAddress|int|string $cellCoordinate

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

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
return: Style

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

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

getConditionalRange(string $coordinate)   X-Ref
No description

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

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

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

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

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

return: array

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

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

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!

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

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!

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

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

param: array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';
param: int $break Break type (type of Worksheet::BREAK_*)
return: $this

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

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

getBreaks()   X-Ref
Get breaks.

return: int[]

mergeCells($range, $behaviour = self::MERGE_CELL_CONTENT_EMPTY)   X-Ref
Set merge on a cell range.

param: AddressRange|array<int>|string $range A simple string containing a Cell range like 'A1:E10'
param: string $behaviour How the merged cells should behave.
return: $this

clearMergeCellsByColumn(string $firstColumn, string $lastColumn, int $firstRow, int $lastRow, string $upperLeft, string $behaviour)   X-Ref
No description

clearMergeCellsByRow(string $firstColumn, int $lastColumnIndex, int $firstRow, int $lastRow, string $upperLeft, string $behaviour)   X-Ref
No description

mergeCellBehaviour(Cell $cell, string $upperLeft, string $behaviour, array $leftCellValue)   X-Ref
No description

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

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 $behaviour How the merged cells should behave.
return: $this

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

param: AddressRange|array<int>|string $range A simple string containing a Cell range like 'A1:E10'
return: $this

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

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

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.

param: string[] $mergeCells
return: $this

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

param: AddressRange|array<int>|CellAddress|int|string $range A simple string containing a Cell range like 'A1:E10'
param: string $password Password to unlock the protection
param: bool $alreadyHashed If the password has already been hashed, set this to true
return: $this

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

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

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

param: AddressRange|array<int>|CellAddress|int|string $range A simple string containing a Cell range like 'A1:E10'
return: $this

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

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

getProtectedCells()   X-Ref
Get protected cells.

return: string[]

getAutoFilter()   X-Ref
Get Autofilter.

return: AutoFilter

setAutoFilter($autoFilterOrRange)   X-Ref
Set AutoFilter.

param: AddressRange|array<int>|AutoFilter|string $autoFilterOrRange
return: $this

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

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

removeAutoFilter()   X-Ref
Remove autofilter.


getTableCollection()   X-Ref
Get collection of Tables.

return: ArrayObject<int, Table>

addTable(Table $table)   X-Ref
Add Table.

return: $this

removeTableByName(string $name)   X-Ref
Remove Table by name.

param: string $name Table name
return: $this

removeTableCollection()   X-Ref
Remove collection of Tables.


getFreezePane()   X-Ref
Get Freeze Pane.

return: null|string

freezePane($coordinate, $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)

param: null|array<int>|CellAddress|string $coordinate Coordinate of the cell as a string, eg: 'C5';
param: null|array<int>|CellAddress|string $topLeftCell default position of the right bottom pane
return: $this

setTopLeftCell(string $topLeftCell)   X-Ref
No description

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

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

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.

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

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

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

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

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

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

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

removeRowDimensions(int $row, int $numberOfRows)   X-Ref
No description

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

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

removeColumnDimensions(int $pColumnIndex, int $numberOfColumns)   X-Ref
No description

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

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

getShowGridlines()   X-Ref
Show gridlines?


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

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

getPrintGridlines()   X-Ref
Print gridlines?


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

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

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


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

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

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


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

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

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


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

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

getComments()   X-Ref
Get comments.

return: Comment[]

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

param: Comment[] $comments
return: $this

removeComment($cellCoordinate)   X-Ref
Remove comment from cell.

param: array<int>|CellAddress|string $cellCoordinate Coordinate of the cell as a string, eg: 'C5';
return: $this

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

param: array<int>|CellAddress|string $cellCoordinate Coordinate of the cell as a string, eg: 'C5';

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

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.

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

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

param: AddressRange|array<int>|CellAddress|int|string $coordinate A simple string containing a Cell range like 'A1:E10'
return: $this

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

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

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

return: bool

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

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

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

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

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

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
return: array

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.

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
return: array

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

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
return: array

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

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

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

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

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!A1:C3") ==> 'A1:C3'
Example: extractSheetTitle("'testSheet 1'!A1", true) ==> ['testSheet 1', 'A1'];
Example: extractSheetTitle("'testSheet 1'!A1:C3", true) ==> ['testSheet 1', 'A1:C3'];
Example: extractSheetTitle("A1", true) ==> ['', 'A1'];
Example: extractSheetTitle("A1:C3", true) ==> ['', 'A1:C3']

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

getHyperlink($cellCoordinate)   X-Ref
Get hyperlink.

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

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

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

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

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

getHyperlinkCollection()   X-Ref
Get collection of hyperlinks.

return: Hyperlink[]

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

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

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

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

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

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

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.

param: string $range
return: string Adjusted range value

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

isEmptyRow(int $rowId, int $definitionOfEmptyFlags = 0)   X-Ref
Returns a boolean true if the specified row contains no cells. By default, this means that no cell records
exist in the collection for this row. false will be returned otherwise.
This rule can be modified by passing a $definitionOfEmptyFlags value:
1 - CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL If the only cells in the collection are null value
cells, then the row will be considered empty.
2 - CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL If the only cells in the collection are empty
string value cells, then the row will be considered empty.
3 - CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL | CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL
If the only cells in the collection are null value or empty string value cells, then the row
will be considered empty.

param: int $definitionOfEmptyFlags

isEmptyColumn(string $columnId, int $definitionOfEmptyFlags = 0)   X-Ref
Returns a boolean true if the specified column contains no cells. By default, this means that no cell records
exist in the collection for this column. false will be returned otherwise.
This rule can be modified by passing a $definitionOfEmptyFlags value:
1 - CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL If the only cells in the collection are null value
cells, then the column will be considered empty.
2 - CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL If the only cells in the collection are empty
string value cells, then the column will be considered empty.
3 - CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL | CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL
If the only cells in the collection are null value or empty string value cells, then the column
will be considered empty.

param: int $definitionOfEmptyFlags

__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.

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

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

return: null|string

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

return: bool

nameRequiresQuotes(string $sheetName)   X-Ref
No description