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: 1605 lines (44 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Spreadsheet:: (92 methods):
  hasMacros()
  setHasMacros()
  setMacrosCode()
  getMacrosCode()
  setMacrosCertificate()
  hasMacrosCertificate()
  getMacrosCertificate()
  discardMacros()
  setRibbonXMLData()
  getRibbonXMLData()
  setRibbonBinObjects()
  getUnparsedLoadedData()
  setUnparsedLoadedData()
  getExtensionOnly()
  getRibbonBinObjects()
  hasRibbon()
  hasRibbonBinObjects()
  sheetCodeNameExists()
  getSheetByCodeName()
  __construct()
  __destruct()
  disconnectWorksheets()
  getCalculationEngine()
  getProperties()
  setProperties()
  getSecurity()
  setSecurity()
  getActiveSheet()
  createSheet()
  sheetNameExists()
  addSheet()
  removeSheetByIndex()
  getSheet()
  getAllSheets()
  getSheetByName()
  getIndex()
  setIndexByName()
  getSheetCount()
  getActiveSheetIndex()
  setActiveSheetIndex()
  setActiveSheetIndexByName()
  getSheetNames()
  addExternalSheet()
  getNamedRanges()
  getNamedFormulae()
  getDefinedNames()
  addNamedRange()
  addNamedFormula()
  addDefinedName()
  getNamedRange()
  getNamedFormula()
  getGlobalDefinedNameByType()
  getLocalDefinedNameByType()
  getDefinedName()
  removeNamedRange()
  removeNamedFormula()
  removeDefinedName()
  getWorksheetIterator()
  copy()
  __clone()
  getCellXfCollection()
  getCellXfByIndex()
  getCellXfByHashCode()
  cellXfExists()
  getDefaultStyle()
  addCellXf()
  removeCellXfByIndex()
  getCellXfSupervisor()
  getCellStyleXfCollection()
  getCellStyleXfByIndex()
  getCellStyleXfByHashCode()
  addCellStyleXf()
  removeCellStyleXfByIndex()
  garbageCollect()
  getID()
  getShowHorizontalScroll()
  setShowHorizontalScroll()
  getShowVerticalScroll()
  setShowVerticalScroll()
  getShowSheetTabs()
  setShowSheetTabs()
  getMinimized()
  setMinimized()
  getAutoFilterDateGrouping()
  setAutoFilterDateGrouping()
  getFirstSheetIndex()
  setFirstSheetIndex()
  getVisibility()
  setVisibility()
  getTabRatio()
  setTabRatio()
  reevaluateAutoFilters()


Class: Spreadsheet  - X-Ref

hasMacros()   X-Ref
The workbook has macros ?

return: bool

setHasMacros($hasMacros)   X-Ref
Define if a workbook has macros.

param: bool $hasMacros true|false

setMacrosCode($macroCode)   X-Ref
Set the macros code.

param: string $macroCode string|null

getMacrosCode()   X-Ref
Return the macros code.

return: null|string

setMacrosCertificate($certificate)   X-Ref
Set the macros certificate.

param: null|string $certificate

hasMacrosCertificate()   X-Ref
Is the project signed ?

return: bool true|false

getMacrosCertificate()   X-Ref
Return the macros certificate.

return: null|string

discardMacros()   X-Ref
Remove all macros, certificate from spreadsheet.


setRibbonXMLData($target, $xmlData)   X-Ref
set ribbon XML data.

param: null|mixed $target
param: null|mixed $xmlData

getRibbonXMLData($what = 'all')   X-Ref
retrieve ribbon XML Data.

return: null|array|string
param: string $what

setRibbonBinObjects($BinObjectsNames, $BinObjectsData)   X-Ref
store binaries ribbon objects (pictures).

param: null|mixed $BinObjectsNames
param: null|mixed $BinObjectsData

getUnparsedLoadedData()   X-Ref
List of unparsed loaded data for export to same format with better compatibility.
It has to be minimized when the library start to support currently unparsed data.

return: array

setUnparsedLoadedData(array $unparsedLoadedData)   X-Ref
List of unparsed loaded data for export to same format with better compatibility.
It has to be minimized when the library start to support currently unparsed data.


getExtensionOnly($path)   X-Ref
return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function).

return: string
param: mixed $path

getRibbonBinObjects($what = 'all')   X-Ref
retrieve Binaries Ribbon Objects.

return: null|array
param: string $what

hasRibbon()   X-Ref
This workbook have a custom UI ?

return: bool

hasRibbonBinObjects()   X-Ref
This workbook have additionnal object for the ribbon ?

return: bool

sheetCodeNameExists($codeName)   X-Ref
Check if a sheet with a specified code name already exists.

return: bool
param: string $codeName Name of the worksheet to check

getSheetByCodeName($codeName)   X-Ref
Get sheet by code name. Warning : sheet don't have always a code name !

return: null|Worksheet
param: string $codeName Sheet name

__construct()   X-Ref
Create a new PhpSpreadsheet with one Worksheet.


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


disconnectWorksheets()   X-Ref
Disconnect all worksheets from this PhpSpreadsheet workbook object,
typically so that the PhpSpreadsheet object can be unset.


getCalculationEngine()   X-Ref
Return the calculation engine for this worksheet.

return: null|Calculation

getProperties()   X-Ref
Get properties.

return: Document\Properties

setProperties(Document\Properties $documentProperties)   X-Ref
Set properties.


getSecurity()   X-Ref
Get security.

return: Document\Security

setSecurity(Document\Security $documentSecurity)   X-Ref
Set security.


getActiveSheet()   X-Ref
Get active sheet.

return: Worksheet

createSheet($sheetIndex = null)   X-Ref
Create sheet and add it to this workbook.

return: Worksheet
param: null|int $sheetIndex Index where sheet should go (0,1,..., or null for last)

sheetNameExists($worksheetName)   X-Ref
Check if a sheet with a specified name already exists.

return: bool
param: string $worksheetName Name of the worksheet to check

addSheet(Worksheet $worksheet, $sheetIndex = null)   X-Ref
Add sheet.

return: Worksheet
param: Worksheet $worksheet The worskeet to add
param: null|int $sheetIndex Index where sheet should go (0,1,..., or null for last)

removeSheetByIndex($sheetIndex)   X-Ref
Remove sheet by index.

param: int $sheetIndex Index position of the worksheet to remove

getSheet($sheetIndex)   X-Ref
Get sheet by index.

return: Worksheet
param: int $sheetIndex Sheet index

getAllSheets()   X-Ref
Get all sheets.

return: Worksheet[]

getSheetByName($worksheetName)   X-Ref
Get sheet by name.

return: null|Worksheet
param: string $worksheetName Sheet name

getIndex(Worksheet $worksheet)   X-Ref
Get index for sheet.

return: int index

setIndexByName($worksheetName, $newIndexPosition)   X-Ref
Set index for sheet by sheet name.

return: int New sheet index
param: string $worksheetName Sheet name to modify index for
param: int $newIndexPosition New index for the sheet

getSheetCount()   X-Ref
Get sheet count.

return: int

getActiveSheetIndex()   X-Ref
Get active sheet index.

return: int Active sheet index

setActiveSheetIndex($worksheetIndex)   X-Ref
Set active sheet index.

return: Worksheet
param: int $worksheetIndex Active sheet index

setActiveSheetIndexByName($worksheetName)   X-Ref
Set active sheet index by name.

return: Worksheet
param: string $worksheetName Sheet title

getSheetNames()   X-Ref
Get sheet names.

return: string[]

addExternalSheet(Worksheet $worksheet, $sheetIndex = null)   X-Ref
Add external sheet.

return: Worksheet
param: Worksheet $worksheet External sheet to add
param: null|int $sheetIndex Index where sheet should go (0,1,..., or null for last)

getNamedRanges()   X-Ref
Get an array of all Named Ranges.

return: DefinedName[]

getNamedFormulae()   X-Ref
No description

getDefinedNames()   X-Ref
No description

addNamedRange(NamedRange $namedRange)   X-Ref
Add a named range.
If a named range with this name already exists, then this will replace the existing value.


addNamedFormula(NamedFormula $namedFormula)   X-Ref
Add a named formula.
If a named formula with this name already exists, then this will replace the existing value.


addDefinedName(DefinedName $definedName)   X-Ref
Add a defined name (either a named range or a named formula).
If a defined named with this name already exists, then this will replace the existing value.


getNamedRange(string $namedRange, ?Worksheet $worksheet = null)   X-Ref
Get named range.

param: null|Worksheet $worksheet Scope. Use null for global scope

getNamedFormula(string $namedFormula, ?Worksheet $worksheet = null)   X-Ref
Get named formula.

param: null|Worksheet $worksheet Scope. Use null for global scope

getGlobalDefinedNameByType(string $name, bool $type)   X-Ref
No description

getLocalDefinedNameByType(string $name, bool $type, ?Worksheet $worksheet = null)   X-Ref
No description

getDefinedName(string $definedName, ?Worksheet $worksheet = null)   X-Ref
Get named range.

param: null|Worksheet $worksheet Scope. Use null for global scope

removeNamedRange(string $namedRange, ?Worksheet $worksheet = null)   X-Ref
Remove named range.

return: $this
param: null|Worksheet $worksheet scope: use null for global scope

removeNamedFormula(string $namedFormula, ?Worksheet $worksheet = null)   X-Ref
Remove named formula.

return: $this
param: null|Worksheet $worksheet scope: use null for global scope

removeDefinedName(string $definedName, ?Worksheet $worksheet = null)   X-Ref
Remove defined name.

return: $this
param: null|Worksheet $worksheet scope: use null for global scope

getWorksheetIterator()   X-Ref
Get worksheet iterator.

return: Iterator

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

return: Spreadsheet

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


getCellXfCollection()   X-Ref
Get the workbook collection of cellXfs.

return: Style[]

getCellXfByIndex($cellStyleIndex)   X-Ref
Get cellXf by index.

return: Style
param: int $cellStyleIndex

getCellXfByHashCode($hashcode)   X-Ref
Get cellXf by hash code.

return: false|Style
param: string $hashcode

cellXfExists(Style $cellStyleIndex)   X-Ref
Check if style exists in style collection.

return: bool

getDefaultStyle()   X-Ref
Get default style.

return: Style

addCellXf(Style $style)   X-Ref
Add a cellXf to the workbook.


removeCellXfByIndex($cellStyleIndex)   X-Ref
Remove cellXf by index. It is ensured that all cells get their xf index updated.

param: int $cellStyleIndex Index to cellXf

getCellXfSupervisor()   X-Ref
Get the cellXf supervisor.

return: Style

getCellStyleXfCollection()   X-Ref
Get the workbook collection of cellStyleXfs.

return: Style[]

getCellStyleXfByIndex($cellStyleIndex)   X-Ref
Get cellStyleXf by index.

return: Style
param: int $cellStyleIndex Index to cellXf

getCellStyleXfByHashCode($hashcode)   X-Ref
Get cellStyleXf by hash code.

return: false|Style
param: string $hashcode

addCellStyleXf(Style $style)   X-Ref
Add a cellStyleXf to the workbook.


removeCellStyleXfByIndex($cellStyleIndex)   X-Ref
Remove cellStyleXf by index.

param: int $cellStyleIndex Index to cellXf

garbageCollect()   X-Ref
Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells
and columns in the workbook.


getID()   X-Ref
Return the unique ID value assigned to this spreadsheet workbook.

return: string

getShowHorizontalScroll()   X-Ref
Get the visibility of the horizonal scroll bar in the application.

return: bool True if horizonal scroll bar is visible

setShowHorizontalScroll($showHorizontalScroll)   X-Ref
Set the visibility of the horizonal scroll bar in the application.

param: bool $showHorizontalScroll True if horizonal scroll bar is visible

getShowVerticalScroll()   X-Ref
Get the visibility of the vertical scroll bar in the application.

return: bool True if vertical scroll bar is visible

setShowVerticalScroll($showVerticalScroll)   X-Ref
Set the visibility of the vertical scroll bar in the application.

param: bool $showVerticalScroll True if vertical scroll bar is visible

getShowSheetTabs()   X-Ref
Get the visibility of the sheet tabs in the application.

return: bool True if the sheet tabs are visible

setShowSheetTabs($showSheetTabs)   X-Ref
Set the visibility of the sheet tabs  in the application.

param: bool $showSheetTabs True if sheet tabs are visible

getMinimized()   X-Ref
Return whether the workbook window is minimized.

return: bool true if workbook window is minimized

setMinimized($minimized)   X-Ref
Set whether the workbook window is minimized.

param: bool $minimized true if workbook window is minimized

getAutoFilterDateGrouping()   X-Ref
Return whether to group dates when presenting the user with
filtering optiomd in the user interface.

return: bool true if workbook window is minimized

setAutoFilterDateGrouping($autoFilterDateGrouping)   X-Ref
Set whether to group dates when presenting the user with
filtering optiomd in the user interface.

param: bool $autoFilterDateGrouping true if workbook window is minimized

getFirstSheetIndex()   X-Ref
Return the first sheet in the book view.

return: int First sheet in book view

setFirstSheetIndex($firstSheetIndex)   X-Ref
Set the first sheet in the book view.

param: int $firstSheetIndex First sheet in book view

getVisibility()   X-Ref
Return the visibility status of the workbook.

This may be one of the following three values:
- visibile

return: string Visible status

setVisibility($visibility)   X-Ref
Set the visibility status of the workbook.

Valid values are:
- 'visible' (self::VISIBILITY_VISIBLE):
Workbook window is visible
- 'hidden' (self::VISIBILITY_HIDDEN):
Workbook window is hidden, but can be shown by the user
via the user interface
- 'veryHidden' (self::VISIBILITY_VERY_HIDDEN):
Workbook window is hidden and cannot be shown in the
user interface.

param: string $visibility visibility status of the workbook

getTabRatio()   X-Ref
Get the ratio between the workbook tabs bar and the horizontal scroll bar.
TabRatio is assumed to be out of 1000 of the horizontal window width.

return: int Ratio between the workbook tabs bar and the horizontal scroll bar

setTabRatio($tabRatio)   X-Ref
Set the ratio between the workbook tabs bar and the horizontal scroll bar
TabRatio is assumed to be out of 1000 of the horizontal window width.

param: int $tabRatio Ratio between the tabs bar and the horizontal scroll bar

reevaluateAutoFilters(bool $resetToMax)   X-Ref
No description