\PhpOffice\PhpSpreadsheetSpreadsheet

Summary

Methods
Properties
Constants
hasMacros()
setHasMacros()
setMacrosCode()
getMacrosCode()
setMacrosCertificate()
hasMacrosCertificate()
getMacrosCertificate()
discardMacros()
setRibbonXMLData()
getRibbonXMLData()
setRibbonBinObjects()
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()
addNamedRange()
getNamedRange()
removeNamedRange()
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()
No public properties found
VISIBILITY_VISIBLE
VISIBILITY_HIDDEN
VISIBILITY_VERY_HIDDEN
No protected methods found
No protected properties found
N/A
getExtensionOnly()
$workbookViewVisibilityValues
$uniqueID
$properties
$security
$workSheetCollection
$calculationEngine
$activeSheetIndex
$namedRanges
$cellXfSupervisor
$cellXfCollection
$cellStyleXfCollection
$hasMacros
$macrosCode
$macrosCertificate
$ribbonXMLData
$ribbonBinObjects
$unparsedLoadedData
$showHorizontalScroll
$showVerticalScroll
$showSheetTabs
$minimized
$autoFilterDateGrouping
$firstSheetIndex
$visibility
$tabRatio
N/A

Constants

VISIBILITY_VISIBLE

VISIBILITY_VISIBLE = 'visible'

VISIBILITY_HIDDEN

VISIBILITY_HIDDEN = 'hidden'

VISIBILITY_VERY_HIDDEN

VISIBILITY_VERY_HIDDEN = 'veryHidden'

Properties

$workbookViewVisibilityValues

$workbookViewVisibilityValues : 

Type

$uniqueID

$uniqueID : string

Unique ID.

Type

string

$workSheetCollection

$workSheetCollection : array<mixed,\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet>

Collection of Worksheet objects.

Type

array<mixed,\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet>

$calculationEngine

$calculationEngine : \PhpOffice\PhpSpreadsheet\Calculation\Calculation

Calculation Engine.

Type

\PhpOffice\PhpSpreadsheet\Calculation\Calculation

$activeSheetIndex

$activeSheetIndex : integer

Active sheet index.

Type

integer

$cellXfSupervisor

$cellXfSupervisor : \PhpOffice\PhpSpreadsheet\Style\Style

CellXf supervisor.

Type

\PhpOffice\PhpSpreadsheet\Style\Style

$cellXfCollection

$cellXfCollection : array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

CellXf collection.

Type

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

$cellStyleXfCollection

$cellStyleXfCollection : array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

CellStyleXf collection.

Type

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

$hasMacros

$hasMacros : boolean

hasMacros : this workbook have macros ?

Type

boolean

$macrosCode

$macrosCode : string

macrosCode : all macros code as binary data (the vbaProject.bin file, this include form, code, etc.), null if no macro.

Type

string

$macrosCertificate

$macrosCertificate : string

macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed.

Type

string

$ribbonXMLData

$ribbonXMLData : null|string

ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI.

Type

null|string

$ribbonBinObjects

$ribbonBinObjects : null|array

ribbonBinObjects : null if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements ignored if $ribbonXMLData is null.

Type

null|array

$unparsedLoadedData

$unparsedLoadedData : array

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.

Type

array

$showHorizontalScroll

$showHorizontalScroll : boolean

Controls visibility of the horizonal scroll bar in the application.

Type

boolean

$showVerticalScroll

$showVerticalScroll : boolean

Controls visibility of the horizonal scroll bar in the application.

Type

boolean

$showSheetTabs

$showSheetTabs : boolean

Controls visibility of the sheet tabs in the application.

Type

boolean

$minimized

$minimized : boolean

Specifies a boolean value that indicates whether the workbook window is minimized.

Type

boolean

$autoFilterDateGrouping

$autoFilterDateGrouping : boolean

Specifies a boolean value that indicates whether to group dates when presenting the user with filtering optiomd in the user interface.

Type

boolean

$firstSheetIndex

$firstSheetIndex : integer

Specifies the index to the first sheet in the book view.

Type

integer

$visibility

$visibility : string

Specifies the visible status of the workbook.

Type

string

$tabRatio

$tabRatio : integer

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

Type

integer

Methods

hasMacros()

hasMacros() : boolean

The workbook has macros ?

Returns

boolean

setHasMacros()

setHasMacros(boolean  $hasMacros) 

Define if a workbook has macros.

Parameters

boolean $hasMacros

true|false

setMacrosCode()

setMacrosCode(string  $macroCode) 

Set the macros code.

Parameters

string $macroCode

string|null

getMacrosCode()

getMacrosCode() : null|string

Return the macros code.

Returns

null|string

setMacrosCertificate()

setMacrosCertificate(null|string  $certificate) 

Set the macros certificate.

Parameters

null|string $certificate

hasMacrosCertificate()

hasMacrosCertificate() : boolean

Is the project signed ?

Returns

boolean —

true|false

getMacrosCertificate()

getMacrosCertificate() : null|string

Return the macros certificate.

Returns

null|string

discardMacros()

discardMacros() 

Remove all macros, certificate from spreadsheet.

setRibbonXMLData()

setRibbonXMLData(null|mixed  $target, null|mixed  $xmlData) 

set ribbon XML data.

Parameters

null|mixed $target
null|mixed $xmlData

getRibbonXMLData()

getRibbonXMLData(string  $what = 'all') : string

retrieve ribbon XML Data.

return string|null|array

Parameters

string $what

Returns

string

setRibbonBinObjects()

setRibbonBinObjects(null|mixed  $BinObjectsNames, null|mixed  $BinObjectsData) 

store binaries ribbon objects (pictures).

Parameters

null|mixed $BinObjectsNames
null|mixed $BinObjectsData

getRibbonBinObjects()

getRibbonBinObjects(string  $what = 'all') : null|array

retrieve Binaries Ribbon Objects.

Parameters

string $what

Returns

null|array

hasRibbon()

hasRibbon() : boolean

This workbook have a custom UI ?

Returns

boolean

hasRibbonBinObjects()

hasRibbonBinObjects() : boolean

This workbook have additionnal object for the ribbon ?

Returns

boolean

sheetCodeNameExists()

sheetCodeNameExists(string  $pSheetCodeName) : boolean

Check if a sheet with a specified code name already exists.

Parameters

string $pSheetCodeName

Name of the worksheet to check

Returns

boolean

getSheetByCodeName()

getSheetByCodeName(string  $pName) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Get sheet by code name. Warning : sheet don't have always a code name !

Parameters

string $pName

Sheet name

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

__construct()

__construct() 

Create a new PhpSpreadsheet with one Worksheet.

__destruct()

__destruct() 

Code to execute when this worksheet is unset().

disconnectWorksheets()

disconnectWorksheets() 

Disconnect all worksheets from this PhpSpreadsheet workbook object, typically so that the PhpSpreadsheet object can be unset.

getCalculationEngine()

getCalculationEngine() : \PhpOffice\PhpSpreadsheet\Calculation\Calculation

Return the calculation engine for this worksheet.

Returns

\PhpOffice\PhpSpreadsheet\Calculation\Calculation

getActiveSheet()

getActiveSheet() : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Get active sheet.

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

createSheet()

createSheet(null|integer  $sheetIndex = null) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Create sheet and add it to this workbook.

Parameters

null|integer $sheetIndex

Index where sheet should go (0,1,..., or null for last)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

sheetNameExists()

sheetNameExists(string  $pSheetName) : boolean

Check if a sheet with a specified name already exists.

Parameters

string $pSheetName

Name of the worksheet to check

Returns

boolean

addSheet()

addSheet(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, null|integer  $iSheetIndex = null) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Add sheet.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet
null|integer $iSheetIndex

Index where sheet should go (0,1,..., or null for last)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

removeSheetByIndex()

removeSheetByIndex(integer  $pIndex) 

Remove sheet by index.

Parameters

integer $pIndex

Active sheet index

Throws

\PhpOffice\PhpSpreadsheet\Exception

getSheet()

getSheet(integer  $pIndex) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Get sheet by index.

Parameters

integer $pIndex

Sheet index

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getAllSheets()

getAllSheets() : array<mixed,\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet>

Get all sheets.

Returns

array<mixed,\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet>

getSheetByName()

getSheetByName(string  $pName) : null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Get sheet by name.

Parameters

string $pName

Sheet name

Returns

null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getIndex()

getIndex(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet) : integer

Get index for sheet.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

integer —

index

setIndexByName()

setIndexByName(string  $sheetName, integer  $newIndex) : integer

Set index for sheet by sheet name.

Parameters

string $sheetName

Sheet name to modify index for

integer $newIndex

New index for the sheet

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

integer —

New sheet index

getSheetCount()

getSheetCount() : integer

Get sheet count.

Returns

integer

getActiveSheetIndex()

getActiveSheetIndex() : integer

Get active sheet index.

Returns

integer —

Active sheet index

setActiveSheetIndex()

setActiveSheetIndex(integer  $pIndex) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set active sheet index.

Parameters

integer $pIndex

Active sheet index

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

setActiveSheetIndexByName()

setActiveSheetIndexByName(string  $pValue) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Set active sheet index by name.

Parameters

string $pValue

Sheet title

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

getSheetNames()

getSheetNames() : array<mixed,string>

Get sheet names.

Returns

array<mixed,string>

addExternalSheet()

addExternalSheet(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet, null|integer  $iSheetIndex = null) : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Add external sheet.

Parameters

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

External sheet to add

null|integer $iSheetIndex

Index where sheet should go (0,1,..., or null for last)

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

addNamedRange()

addNamedRange(\PhpOffice\PhpSpreadsheet\NamedRange  $namedRange) : boolean

Add named range.

Parameters

\PhpOffice\PhpSpreadsheet\NamedRange $namedRange

Returns

boolean

getNamedRange()

getNamedRange(string  $namedRange, null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet = null) : null|\PhpOffice\PhpSpreadsheet\NamedRange

Get named range.

Parameters

string $namedRange
null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

Scope. Use null for global scope

Returns

null|\PhpOffice\PhpSpreadsheet\NamedRange

removeNamedRange()

removeNamedRange(string  $namedRange, null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet  $pSheet = null) : $this

Remove named range.

Parameters

string $namedRange
null|\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $pSheet

scope: use null for global scope

Returns

$this

__clone()

__clone() 

Implement PHP __clone to create a deep clone, not just a shallow copy.

getCellXfCollection()

getCellXfCollection() : array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

Get the workbook collection of cellXfs.

Returns

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

getCellXfByIndex()

getCellXfByIndex(integer  $pIndex) : \PhpOffice\PhpSpreadsheet\Style\Style

Get cellXf by index.

Parameters

integer $pIndex

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

getCellXfByHashCode()

getCellXfByHashCode(string  $pValue) : false|\PhpOffice\PhpSpreadsheet\Style\Style

Get cellXf by hash code.

Parameters

string $pValue

Returns

false|\PhpOffice\PhpSpreadsheet\Style\Style

cellXfExists()

cellXfExists(\PhpOffice\PhpSpreadsheet\Style\Style  $pCellStyle) : boolean

Check if style exists in style collection.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $pCellStyle

Returns

boolean

getDefaultStyle()

getDefaultStyle() : \PhpOffice\PhpSpreadsheet\Style\Style

Get default style.

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

addCellXf()

addCellXf(\PhpOffice\PhpSpreadsheet\Style\Style  $style) 

Add a cellXf to the workbook.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $style

removeCellXfByIndex()

removeCellXfByIndex(integer  $pIndex) 

Remove cellXf by index. It is ensured that all cells get their xf index updated.

Parameters

integer $pIndex

Index to cellXf

Throws

\PhpOffice\PhpSpreadsheet\Exception

getCellXfSupervisor()

getCellXfSupervisor() : \PhpOffice\PhpSpreadsheet\Style\Style

Get the cellXf supervisor.

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

getCellStyleXfCollection()

getCellStyleXfCollection() : array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

Get the workbook collection of cellStyleXfs.

Returns

array<mixed,\PhpOffice\PhpSpreadsheet\Style\Style>

getCellStyleXfByIndex()

getCellStyleXfByIndex(integer  $pIndex) : \PhpOffice\PhpSpreadsheet\Style\Style

Get cellStyleXf by index.

Parameters

integer $pIndex

Index to cellXf

Returns

\PhpOffice\PhpSpreadsheet\Style\Style

getCellStyleXfByHashCode()

getCellStyleXfByHashCode(string  $pValue) : false|\PhpOffice\PhpSpreadsheet\Style\Style

Get cellStyleXf by hash code.

Parameters

string $pValue

Returns

false|\PhpOffice\PhpSpreadsheet\Style\Style

addCellStyleXf()

addCellStyleXf(\PhpOffice\PhpSpreadsheet\Style\Style  $pStyle) 

Add a cellStyleXf to the workbook.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $pStyle

removeCellStyleXfByIndex()

removeCellStyleXfByIndex(integer  $pIndex) 

Remove cellStyleXf by index.

Parameters

integer $pIndex

Index to cellXf

Throws

\PhpOffice\PhpSpreadsheet\Exception

garbageCollect()

garbageCollect() 

Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells and columns in the workbook.

getID()

getID() : string

Return the unique ID value assigned to this spreadsheet workbook.

Returns

string

getShowHorizontalScroll()

getShowHorizontalScroll() : boolean

Get the visibility of the horizonal scroll bar in the application.

Returns

boolean —

True if horizonal scroll bar is visible

setShowHorizontalScroll()

setShowHorizontalScroll(boolean  $showHorizontalScroll) 

Set the visibility of the horizonal scroll bar in the application.

Parameters

boolean $showHorizontalScroll

True if horizonal scroll bar is visible

getShowVerticalScroll()

getShowVerticalScroll() : boolean

Get the visibility of the vertical scroll bar in the application.

Returns

boolean —

True if vertical scroll bar is visible

setShowVerticalScroll()

setShowVerticalScroll(boolean  $showVerticalScroll) 

Set the visibility of the vertical scroll bar in the application.

Parameters

boolean $showVerticalScroll

True if vertical scroll bar is visible

getShowSheetTabs()

getShowSheetTabs() : boolean

Get the visibility of the sheet tabs in the application.

Returns

boolean —

True if the sheet tabs are visible

setShowSheetTabs()

setShowSheetTabs(boolean  $showSheetTabs) 

Set the visibility of the sheet tabs in the application.

Parameters

boolean $showSheetTabs

True if sheet tabs are visible

getMinimized()

getMinimized() : boolean

Return whether the workbook window is minimized.

Returns

boolean —

true if workbook window is minimized

setMinimized()

setMinimized(boolean  $minimized) 

Set whether the workbook window is minimized.

Parameters

boolean $minimized

true if workbook window is minimized

getAutoFilterDateGrouping()

getAutoFilterDateGrouping() : boolean

Return whether to group dates when presenting the user with filtering optiomd in the user interface.

Returns

boolean —

true if workbook window is minimized

setAutoFilterDateGrouping()

setAutoFilterDateGrouping(boolean  $autoFilterDateGrouping) 

Set whether to group dates when presenting the user with filtering optiomd in the user interface.

Parameters

boolean $autoFilterDateGrouping

true if workbook window is minimized

getFirstSheetIndex()

getFirstSheetIndex() : integer

Return the first sheet in the book view.

Returns

integer —

First sheet in book view

setFirstSheetIndex()

setFirstSheetIndex(integer  $firstSheetIndex) 

Set the first sheet in the book view.

Parameters

integer $firstSheetIndex

First sheet in book view

Throws

\PhpOffice\PhpSpreadsheet\Exception

if the given value is invalid

getVisibility()

getVisibility() : string

Return the visibility status of the workbook.

This may be one of the following three values:

  • visibile

Returns

string —

Visible status

setVisibility()

setVisibility(string  $visibility) 

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.

Parameters

string $visibility

visibility status of the workbook

Throws

\PhpOffice\PhpSpreadsheet\Exception

if the given value is invalid

getTabRatio()

getTabRatio() : integer

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.

Returns

integer —

Ratio between the workbook tabs bar and the horizontal scroll bar

setTabRatio()

setTabRatio(integer  $tabRatio) 

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.

Parameters

integer $tabRatio

Ratio between the tabs bar and the horizontal scroll bar

Throws

\PhpOffice\PhpSpreadsheet\Exception

if the given value is invalid

getExtensionOnly()

getExtensionOnly(mixed  $path) : string

return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function).

Parameters

mixed $path

Returns

string