Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

(no description)

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

Defines 1 class

Spreadsheet:: (91 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()


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 string|null|array

param: string $what
return: 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($pSheetCodeName)   X-Ref
Check if a sheet with a specified code name already exists.

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

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

param: string $pName Sheet name
return: 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: Calculation

getProperties()   X-Ref
Get properties.

return: Document\Properties

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


getSecurity()   X-Ref
Get security.

return: Document\Security

setSecurity(Document\Security $pValue)   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($pSheetName)   X-Ref
Check if a sheet with a specified name already exists.

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

addSheet(Worksheet $pSheet, $iSheetIndex = null)   X-Ref
Add sheet.

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

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

param: int $pIndex Active sheet index

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

param: int $pIndex Sheet index
return: Worksheet

getAllSheets()   X-Ref
Get all sheets.

return: Worksheet[]

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

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

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

return: int index

setIndexByName($sheetName, $newIndex)   X-Ref
Set index for sheet by sheet name.

param: string $sheetName Sheet name to modify index for
param: int $newIndex 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($pIndex)   X-Ref
Set active sheet index.

param: int $pIndex Active sheet index
return: Worksheet

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

param: string $pValue Sheet title
return: Worksheet

getSheetNames()   X-Ref
Get sheet names.

return: string[]

addExternalSheet(Worksheet $pSheet, $iSheetIndex = null)   X-Ref
Add external sheet.

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

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

return: NamedRange[]

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 $pSheet = null)   X-Ref
Get named range.

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

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

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

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

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

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

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

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

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

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

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

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

param: null|Worksheet $pSheet 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
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($pIndex)   X-Ref
Get cellXf by index.

param: int $pIndex
return: Style

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

param: string $pValue
return: false|Style

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

param: Style $pCellStyle
return: bool

getDefaultStyle()   X-Ref
Get default style.

return: Style

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


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

param: int $pIndex Index to cellXf

getCellXfSupervisor()   X-Ref
Get the cellXf supervisor.

return: Style

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

return: Style[]

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

param: int $pIndex Index to cellXf
return: Style

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

param: string $pValue
return: false|Style

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


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

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