class PHPExcel

PHPExcel

Copyright (c) 2006 - 2015 PHPExcel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Methods

boolean
hasMacros()

The workbook has macros ?

setHasMacros(boolean $hasMacros = false)

Define if a workbook has macros

setMacrosCode(string $MacrosCode = null)

Set the macros code

string|null
getMacrosCode()

Return the macros code

setMacrosCertificate(string|null $Certificate = null)

Set the macros certificate

boolean
hasMacrosCertificate()

Is the project signed ?

string|null
getMacrosCertificate()

Return the macros certificate

discardMacros()

Remove all macros, certificate from spreadsheet

setRibbonXMLData($Target = null, $XMLData = null)

set ribbon XML data

getRibbonXMLData($What = 'all')

retrieve ribbon XML Data

setRibbonBinObjects($BinObjectsNames = null, $BinObjectsData = null)

store binaries ribbon objects (pictures)

getRibbonBinObjects($What = 'all')

retrieve Binaries Ribbon Objects

boolean
hasRibbon()

This workbook have a custom UI ?

boolean
hasRibbonBinObjects()

This workbook have additionnal object for the ribbon ?

boolean
sheetCodeNameExists(string $pSheetCodeName)

Check if a sheet with a specified code name already exists

getSheetByCodeName(string $pName = '')

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

__construct()

Create a new PHPExcel with one Worksheet

__destruct()

Code to execute when this worksheet is unset()

disconnectWorksheets()

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

getCalculationEngine()

Return the calculation engine for this worksheet

setProperties(PHPExcel_DocumentProperties $pValue)

Set properties

setSecurity(PHPExcel_DocumentSecurity $pValue)

Set security

getActiveSheet()

Get active sheet

createSheet(int|null $iSheetIndex = null)

Create sheet and add it to this workbook

boolean
sheetNameExists(string $pSheetName)

Check if a sheet with a specified name already exists

addSheet(PHPExcel_Worksheet $pSheet, int|null $iSheetIndex = null)

Add sheet

removeSheetByIndex(int $pIndex)

Remove sheet by index

getSheet(int $pIndex)

Get sheet by index

getAllSheets()

Get all sheets

getSheetByName(string $pName = '')

Get sheet by name

int
getIndex(PHPExcel_Worksheet $pSheet)

Get index for sheet

int
setIndexByName(string $sheetName, int $newIndex)

Set index for sheet by sheet name.

int
getSheetCount()

Get sheet count

int
getActiveSheetIndex()

Get active sheet index

setActiveSheetIndex(int $pIndex)

Set active sheet index

setActiveSheetIndexByName(string $pValue = '')

Set active sheet index by name

string[]
getSheetNames()

Get sheet names

addExternalSheet(PHPExcel_Worksheet $pSheet, int|null $iSheetIndex = null)

Add external sheet

getNamedRanges()

Get named ranges

boolean
addNamedRange(PHPExcel_NamedRange $namedRange)

Add named range

getNamedRange(string $namedRange, PHPExcel_Worksheet $pSheet = null)

Get named range

removeNamedRange(string $namedRange, PHPExcel_Worksheet $pSheet = null)

Remove named range

copy()

Copy workbook (!= clone!)

__clone()

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

getCellXfCollection()

Get the workbook collection of cellXfs

getCellXfByIndex(int $pIndex)

Get cellXf by index

PHPExcel_Style|boolean
getCellXfByHashCode(string $pValue = '')

Get cellXf by hash code

boolean
cellXfExists(PHPExcel_Style $pCellStyle = null)

Check if style exists in style collection

getDefaultStyle()

Get default style

addCellXf(PHPExcel_Style $style)

Add a cellXf to the workbook

removeCellXfByIndex(integer $pIndex)

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

getCellXfSupervisor()

Get the cellXf supervisor

getCellStyleXfCollection()

Get the workbook collection of cellStyleXfs

getCellStyleXfByIndex(integer $pIndex)

Get cellStyleXf by index

PHPExcel_Style|boolean
getCellStyleXfByHashCode(string $pValue = '')

Get cellStyleXf by hash code

addCellStyleXf(PHPExcel_Style $pStyle)

Add a cellStyleXf to the workbook

removeCellStyleXfByIndex(integer $pIndex)

Remove cellStyleXf by index

garbageCollect()

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

string
getID()

Return the unique ID value assigned to this spreadsheet workbook

Details

at line 157
boolean hasMacros()

The workbook has macros ?

Return Value

boolean true if workbook has macros, false if not

at line 167
setHasMacros(boolean $hasMacros = false)

Define if a workbook has macros

Parameters

boolean $hasMacros true|false

at line 177
setMacrosCode(string $MacrosCode = null)

Set the macros code

Parameters

string $MacrosCode string|null

at line 188
string|null getMacrosCode()

Return the macros code

Return Value

string|null

at line 198
setMacrosCertificate(string|null $Certificate = null)

Set the macros certificate

Parameters

string|null $Certificate

at line 208
boolean hasMacrosCertificate()

Is the project signed ?

Return Value

boolean true|false

at line 218
string|null getMacrosCertificate()

Return the macros certificate

Return Value

string|null

at line 227
discardMacros()

Remove all macros, certificate from spreadsheet

at line 238
setRibbonXMLData($Target = null, $XMLData = null)

set ribbon XML data

Parameters

$Target
$XMLData

at line 252
getRibbonXMLData($What = 'all')

retrieve ribbon XML Data

return string|null|array

Parameters

$What

at line 275
setRibbonBinObjects($BinObjectsNames = null, $BinObjectsData = null)

store binaries ribbon objects (pictures)

Parameters

$BinObjectsNames
$BinObjectsData

at line 296
getRibbonBinObjects($What = 'all')

retrieve Binaries Ribbon Objects

Parameters

$What

at line 328
boolean hasRibbon()

This workbook have a custom UI ?

Return Value

boolean true|false

at line 338
boolean hasRibbonBinObjects()

This workbook have additionnal object for the ribbon ?

Return Value

boolean true|false

at line 349
boolean sheetCodeNameExists(string $pSheetCodeName)

Check if a sheet with a specified code name already exists

Parameters

string $pSheetCodeName Name of the worksheet to check

Return Value

boolean

at line 360
PHPExcel_Worksheet getSheetByCodeName(string $pName = '')

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

Parameters

string $pName Sheet name

Return Value

PHPExcel_Worksheet

at line 375
__construct()

Create a new PHPExcel with one Worksheet

at line 407
__destruct()

Code to execute when this worksheet is unset()

at line 418
disconnectWorksheets()

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

at line 434
PHPExcel_Calculation getCalculationEngine()

Return the calculation engine for this worksheet

Return Value

PHPExcel_Calculation

at line 444
PHPExcel_DocumentProperties getProperties()

Get properties

at line 454
setProperties(PHPExcel_DocumentProperties $pValue)

Set properties

Parameters

PHPExcel_DocumentProperties $pValue

at line 464
PHPExcel_DocumentSecurity getSecurity()

Get security

at line 474
setSecurity(PHPExcel_DocumentSecurity $pValue)

Set security

Parameters

PHPExcel_DocumentSecurity $pValue

at line 486
PHPExcel_Worksheet getActiveSheet()

Get active sheet

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 498
PHPExcel_Worksheet createSheet(int|null $iSheetIndex = null)

Create sheet and add it to this workbook

Parameters

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

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 511
boolean sheetNameExists(string $pSheetName)

Check if a sheet with a specified name already exists

Parameters

string $pSheetName Name of the worksheet to check

Return Value

boolean

at line 524
PHPExcel_Worksheet addSheet(PHPExcel_Worksheet $pSheet, int|null $iSheetIndex = null)

Add sheet

Parameters

PHPExcel_Worksheet $pSheet
int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 565
removeSheetByIndex(int $pIndex)

Remove sheet by index

Parameters

int $pIndex Active sheet index

Exceptions

PHPExcel_Exception

at line 591
PHPExcel_Worksheet getSheet(int $pIndex)

Get sheet by index

Parameters

int $pIndex Sheet index

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 608
PHPExcel_Worksheet[] getAllSheets()

Get all sheets

Return Value

PHPExcel_Worksheet[]

at line 619
PHPExcel_Worksheet getSheetByName(string $pName = '')

Get sheet by name

Parameters

string $pName Sheet name

Return Value

PHPExcel_Worksheet

at line 638
int getIndex(PHPExcel_Worksheet $pSheet)

Get index for sheet

Parameters

PHPExcel_Worksheet $pSheet

Return Value

int Sheet index

Exceptions

PHPExcel_Exception

at line 657
int setIndexByName(string $sheetName, int $newIndex)

Set index for sheet by sheet name.

Parameters

string $sheetName Sheet name to modify index for
int $newIndex New index for the sheet

Return Value

int New sheet index

Exceptions

PHPExcel_Exception

at line 679
int getSheetCount()

Get sheet count

Return Value

int

at line 689
int getActiveSheetIndex()

Get active sheet index

Return Value

int Active sheet index

at line 701
PHPExcel_Worksheet setActiveSheetIndex(int $pIndex)

Set active sheet index

Parameters

int $pIndex Active sheet index

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 722
PHPExcel_Worksheet setActiveSheetIndexByName(string $pValue = '')

Set active sheet index by name

Parameters

string $pValue Sheet title

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 737
string[] getSheetNames()

Get sheet names

Return Value

string[]

at line 756
PHPExcel_Worksheet addExternalSheet(PHPExcel_Worksheet $pSheet, int|null $iSheetIndex = null)

Add external sheet

Parameters

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

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 787
PHPExcel_NamedRange[] getNamedRanges()

Get named ranges

Return Value

PHPExcel_NamedRange[]

at line 798
boolean addNamedRange(PHPExcel_NamedRange $namedRange)

Add named range

Parameters

PHPExcel_NamedRange $namedRange

Return Value

boolean

at line 817
PHPExcel_NamedRange|null getNamedRange(string $namedRange, PHPExcel_Worksheet $pSheet = null)

Get named range

Parameters

string $namedRange
PHPExcel_Worksheet $pSheet Scope. Use null for global scope

Return Value

PHPExcel_NamedRange|null

at line 843
PHPExcel removeNamedRange(string $namedRange, PHPExcel_Worksheet $pSheet = null)

Remove named range

Parameters

string $namedRange
PHPExcel_Worksheet $pSheet Scope: use null for global scope.

Return Value

PHPExcel

at line 862
PHPExcel_WorksheetIterator getWorksheetIterator()

Get worksheet iterator

at line 872
PHPExcel copy()

Copy workbook (!= clone!)

Return Value

PHPExcel

at line 888
__clone()

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

at line 902
PHPExcel_Style[] getCellXfCollection()

Get the workbook collection of cellXfs

Return Value

PHPExcel_Style[]

at line 913
PHPExcel_Style getCellXfByIndex(int $pIndex)

Get cellXf by index

Parameters

int $pIndex

Return Value

PHPExcel_Style

at line 924
PHPExcel_Style|boolean getCellXfByHashCode(string $pValue = '')

Get cellXf by hash code

Parameters

string $pValue

Return Value

PHPExcel_Style|boolean False if no match found

at line 940
boolean cellXfExists(PHPExcel_Style $pCellStyle = null)

Check if style exists in style collection

Parameters

PHPExcel_Style $pCellStyle

Return Value

boolean

at line 951
PHPExcel_Style getDefaultStyle()

Get default style

Return Value

PHPExcel_Style

Exceptions

PHPExcel_Exception

at line 964
addCellXf(PHPExcel_Style $style)

Add a cellXf to the workbook

Parameters

PHPExcel_Style $style

at line 976
removeCellXfByIndex(integer $pIndex)

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

Parameters

integer $pIndex Index to cellXf

Exceptions

PHPExcel_Exception

at line 1006
PHPExcel_Style getCellXfSupervisor()

Get the cellXf supervisor

Return Value

PHPExcel_Style

at line 1016
PHPExcel_Style[] getCellStyleXfCollection()

Get the workbook collection of cellStyleXfs

Return Value

PHPExcel_Style[]

at line 1027
PHPExcel_Style getCellStyleXfByIndex(integer $pIndex)

Get cellStyleXf by index

Parameters

integer $pIndex Index to cellXf

Return Value

PHPExcel_Style

at line 1038
PHPExcel_Style|boolean getCellStyleXfByHashCode(string $pValue = '')

Get cellStyleXf by hash code

Parameters

string $pValue

Return Value

PHPExcel_Style|boolean False if no match found

at line 1053
addCellStyleXf(PHPExcel_Style $pStyle)

Add a cellStyleXf to the workbook

Parameters

PHPExcel_Style $pStyle

at line 1065
removeCellStyleXfByIndex(integer $pIndex)

Remove cellStyleXf by index

Parameters

integer $pIndex Index to cellXf

Exceptions

PHPExcel_Exception

at line 1078
garbageCollect()

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

at line 1160
string getID()

Return the unique ID value assigned to this spreadsheet workbook

Return Value

string