Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

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

(no description)

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

Defines 1 class

Spreadsheet:: (98 methods):
  getTheme()
  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()
  getSheetByNameOrThrow()
  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()
  getSharedComponent()
  __serialize()
  jsonSerialize()
  resetThemeFonts()


Class: Spreadsheet  - X-Ref

getTheme()   X-Ref
No description

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.

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

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

param: mixed $path
return: string

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

param: string $what
return: null|array

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.

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

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

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

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

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

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

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

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

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

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.

param: int $sheetIndex Sheet index
return: Worksheet

getAllSheets()   X-Ref
Get all sheets.

return: Worksheet[]

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

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

getSheetByNameOrThrow(string $worksheetName)   X-Ref
Get sheet by name, throwing exception if not found.


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

return: int index

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

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

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.

param: int $worksheetIndex Active sheet index
return: Worksheet

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

param: string $worksheetName Sheet title
return: Worksheet

getSheetNames()   X-Ref
Get sheet names.

return: string[]

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

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

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.

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

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

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

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

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

getWorksheetIterator()   X-Ref
Get worksheet iterator.

return: Iterator

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

return: Spreadsheet

__clone()   X-Ref
No description

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

return: Style[]

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

param: int $cellStyleIndex
return: Style

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

param: string $hashcode
return: false|Style

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.

param: int $cellStyleIndex Index to cellXf
return: Style

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

param: string $hashcode
return: false|Style

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: null|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

getSharedComponent()   X-Ref
Silliness to mollify Scrutinizer.


__serialize()   X-Ref

return: mixed

jsonSerialize()   X-Ref


resetThemeFonts()   X-Ref
No description