class Spreadsheet (View source)

Constants

VISIBILITY_VISIBLE

VISIBILITY_HIDDEN

VISIBILITY_VERY_HIDDEN

Methods

bool
hasMacros()

The workbook has macros ?

setHasMacros(bool $hasMacros)

Define if a workbook has macros.

setMacrosCode(string $macroCode)

Set the macros code.

null|string
getMacrosCode()

Return the macros code.

setMacrosCertificate(null|string $certificate)

Set the macros certificate.

bool
hasMacrosCertificate()

Is the project signed ?

null|string
getMacrosCertificate()

Return the macros certificate.

discardMacros()

Remove all macros, certificate from spreadsheet.

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

set ribbon XML data.

string
getRibbonXMLData(string $what = 'all')

retrieve ribbon XML Data.

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

store binaries ribbon objects (pictures).

array
getUnparsedLoadedData()

List of unparsed loaded data for export to same format with better compatibility.

setUnparsedLoadedData(array $unparsedLoadedData)

List of unparsed loaded data for export to same format with better compatibility.

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

retrieve Binaries Ribbon Objects.

bool
hasRibbon()

This workbook have a custom UI ?

bool
hasRibbonBinObjects()

This workbook have additionnal object for the ribbon ?

bool
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 PhpSpreadsheet with one Worksheet.

__destruct()

Code to execute when this worksheet is unset().

disconnectWorksheets()

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

getCalculationEngine()

Return the calculation engine for this worksheet.

getProperties()

Get properties.

setProperties(Properties $pValue)

Set properties.

getSecurity()

Get security.

setSecurity(Security $pValue)

Set security.

getActiveSheet()

Get active sheet.

createSheet(null|int $sheetIndex = null)

Create sheet and add it to this workbook.

bool
sheetNameExists(string $pSheetName)

Check if a sheet with a specified name already exists.

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

Add sheet.

removeSheetByIndex(int $pIndex)

Remove sheet by index.

getSheet(int $pIndex)

Get sheet by index.

getAllSheets()

Get all sheets.

null|Worksheet
getSheetByName(string $pName)

Get sheet by name.

int
getIndex(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(Worksheet $pSheet, null|int $iSheetIndex = null)

Add external sheet.

getNamedRanges()

Get named ranges.

bool
addNamedRange(NamedRange $namedRange)

Add named range.

null|NamedRange
getNamedRange(string $namedRange, Worksheet $pSheet = null)

Get named range.

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

Remove named range.

getWorksheetIterator()

Get worksheet iterator.

copy()

Copy workbook (!= clone!).

__clone()

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

Style[]
getCellXfCollection()

Get the workbook collection of cellXfs.

getCellXfByIndex(int $pIndex)

Get cellXf by index.

false|Style
getCellXfByHashCode(string $pValue)

Get cellXf by hash code.

bool
cellXfExists(Style $pCellStyle)

Check if style exists in style collection.

getDefaultStyle()

Get default style.

addCellXf(Style $style)

Add a cellXf to the workbook.

removeCellXfByIndex(int $pIndex)

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

getCellXfSupervisor()

Get the cellXf supervisor.

Style[]
getCellStyleXfCollection()

Get the workbook collection of cellStyleXfs.

getCellStyleXfByIndex(int $pIndex)

Get cellStyleXf by index.

false|Style
getCellStyleXfByHashCode(string $pValue)

Get cellStyleXf by hash code.

addCellStyleXf(Style $pStyle)

Add a cellStyleXf to the workbook.

removeCellStyleXfByIndex(int $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.

bool
getShowHorizontalScroll()

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

setShowHorizontalScroll(bool $showHorizontalScroll)

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

bool
getShowVerticalScroll()

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

setShowVerticalScroll(bool $showVerticalScroll)

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

bool
getShowSheetTabs()

Get the visibility of the sheet tabs in the application.

setShowSheetTabs(bool $showSheetTabs)

Set the visibility of the sheet tabs in the application.

bool
getMinimized()

Return whether the workbook window is minimized.

setMinimized(bool $minimized)

Set whether the workbook window is minimized.

bool
getAutoFilterDateGrouping()

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

setAutoFilterDateGrouping(bool $autoFilterDateGrouping)

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

int
getFirstSheetIndex()

Return the first sheet in the book view.

setFirstSheetIndex(int $firstSheetIndex)

Set the first sheet in the book view.

string
getVisibility()

Return the visibility status of the workbook.

setVisibility(string $visibility)

Set the visibility status of the workbook.

int
getTabRatio()

Get the ratio between the workbook tabs bar and the horizontal scroll bar.

setTabRatio(int $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.

Details

bool hasMacros()

The workbook has macros ?

Return Value

bool

setHasMacros(bool $hasMacros)

Define if a workbook has macros.

Parameters

bool $hasMacros true|false

setMacrosCode(string $macroCode)

Set the macros code.

Parameters

string $macroCode string|null

null|string getMacrosCode()

Return the macros code.

Return Value

null|string

setMacrosCertificate(null|string $certificate)

Set the macros certificate.

Parameters

null|string $certificate

bool hasMacrosCertificate()

Is the project signed ?

Return Value

bool true|false

null|string getMacrosCertificate()

Return the macros certificate.

Return Value

null|string

discardMacros()

Remove all macros, certificate from spreadsheet.

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

set ribbon XML data.

Parameters

null|mixed $target
null|mixed $xmlData

string getRibbonXMLData(string $what = 'all')

retrieve ribbon XML Data.

return string|null|array

Parameters

string $what

Return Value

string

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

store binaries ribbon objects (pictures).

Parameters

null|mixed $BinObjectsNames
null|mixed $BinObjectsData

array getUnparsedLoadedData()

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 Value

array

setUnparsedLoadedData(array $unparsedLoadedData)

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.

Parameters

array $unparsedLoadedData

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

retrieve Binaries Ribbon Objects.

Parameters

string $what

Return Value

null|array

bool hasRibbon()

This workbook have a custom UI ?

Return Value

bool

bool hasRibbonBinObjects()

This workbook have additionnal object for the ribbon ?

Return Value

bool

bool 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

bool

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

Worksheet

__construct()

Create a new PhpSpreadsheet with one Worksheet.

__destruct()

Code to execute when this worksheet is unset().

disconnectWorksheets()

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

Calculation getCalculationEngine()

Return the calculation engine for this worksheet.

Return Value

Calculation

Properties getProperties()

Get properties.

Return Value

Properties

setProperties(Properties $pValue)

Set properties.

Parameters

Properties $pValue

Security getSecurity()

Get security.

Return Value

Security

setSecurity(Security $pValue)

Set security.

Parameters

Security $pValue

Worksheet getActiveSheet()

Get active sheet.

Return Value

Worksheet

Exceptions

Exception

Worksheet createSheet(null|int $sheetIndex = null)

Create sheet and add it to this workbook.

Parameters

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

Return Value

Worksheet

Exceptions

Exception

bool sheetNameExists(string $pSheetName)

Check if a sheet with a specified name already exists.

Parameters

string $pSheetName Name of the worksheet to check

Return Value

bool

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

Add sheet.

Parameters

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

Return Value

Worksheet

Exceptions

Exception

removeSheetByIndex(int $pIndex)

Remove sheet by index.

Parameters

int $pIndex Active sheet index

Exceptions

Exception

Worksheet getSheet(int $pIndex)

Get sheet by index.

Parameters

int $pIndex Sheet index

Return Value

Worksheet

Exceptions

Exception

Worksheet[] getAllSheets()

Get all sheets.

Return Value

Worksheet[]

null|Worksheet getSheetByName(string $pName)

Get sheet by name.

Parameters

string $pName Sheet name

Return Value

null|Worksheet

int getIndex(Worksheet $pSheet)

Get index for sheet.

Parameters

Worksheet $pSheet

Return Value

int index

Exceptions

Exception

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

Exception

int getSheetCount()

Get sheet count.

Return Value

int

int getActiveSheetIndex()

Get active sheet index.

Return Value

int Active sheet index

Worksheet setActiveSheetIndex(int $pIndex)

Set active sheet index.

Parameters

int $pIndex Active sheet index

Return Value

Worksheet

Exceptions

Exception

Worksheet setActiveSheetIndexByName(string $pValue)

Set active sheet index by name.

Parameters

string $pValue Sheet title

Return Value

Worksheet

Exceptions

Exception

string[] getSheetNames()

Get sheet names.

Return Value

string[]

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

Add external sheet.

Parameters

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

Return Value

Worksheet

Exceptions

Exception

NamedRange[] getNamedRanges()

Get named ranges.

Return Value

NamedRange[]

bool addNamedRange(NamedRange $namedRange)

Add named range.

Parameters

NamedRange $namedRange

Return Value

bool

null|NamedRange getNamedRange(string $namedRange, Worksheet $pSheet = null)

Get named range.

Parameters

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

Return Value

null|NamedRange

Spreadsheet removeNamedRange(string $namedRange, Worksheet $pSheet = null)

Remove named range.

Parameters

string $namedRange
Worksheet $pSheet scope: use null for global scope

Return Value

Spreadsheet

Iterator getWorksheetIterator()

Get worksheet iterator.

Return Value

Iterator

Spreadsheet copy()

Copy workbook (!= clone!).

Return Value

Spreadsheet

__clone()

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

Style[] getCellXfCollection()

Get the workbook collection of cellXfs.

Return Value

Style[]

Style getCellXfByIndex(int $pIndex)

Get cellXf by index.

Parameters

int $pIndex

Return Value

Style

false|Style getCellXfByHashCode(string $pValue)

Get cellXf by hash code.

Parameters

string $pValue

Return Value

false|Style

bool cellXfExists(Style $pCellStyle)

Check if style exists in style collection.

Parameters

Style $pCellStyle

Return Value

bool

Style getDefaultStyle()

Get default style.

Return Value

Style

Exceptions

Exception

addCellXf(Style $style)

Add a cellXf to the workbook.

Parameters

Style $style

removeCellXfByIndex(int $pIndex)

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

Parameters

int $pIndex Index to cellXf

Exceptions

Exception

Style getCellXfSupervisor()

Get the cellXf supervisor.

Return Value

Style

Style[] getCellStyleXfCollection()

Get the workbook collection of cellStyleXfs.

Return Value

Style[]

Style getCellStyleXfByIndex(int $pIndex)

Get cellStyleXf by index.

Parameters

int $pIndex Index to cellXf

Return Value

Style

false|Style getCellStyleXfByHashCode(string $pValue)

Get cellStyleXf by hash code.

Parameters

string $pValue

Return Value

false|Style

addCellStyleXf(Style $pStyle)

Add a cellStyleXf to the workbook.

Parameters

Style $pStyle

removeCellStyleXfByIndex(int $pIndex)

Remove cellStyleXf by index.

Parameters

int $pIndex Index to cellXf

Exceptions

Exception

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.

Return Value

string

bool getShowHorizontalScroll()

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

Return Value

bool True if horizonal scroll bar is visible

setShowHorizontalScroll(bool $showHorizontalScroll)

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

Parameters

bool $showHorizontalScroll True if horizonal scroll bar is visible

bool getShowVerticalScroll()

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

Return Value

bool True if vertical scroll bar is visible

setShowVerticalScroll(bool $showVerticalScroll)

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

Parameters

bool $showVerticalScroll True if vertical scroll bar is visible

bool getShowSheetTabs()

Get the visibility of the sheet tabs in the application.

Return Value

bool True if the sheet tabs are visible

setShowSheetTabs(bool $showSheetTabs)

Set the visibility of the sheet tabs in the application.

Parameters

bool $showSheetTabs True if sheet tabs are visible

bool getMinimized()

Return whether the workbook window is minimized.

Return Value

bool true if workbook window is minimized

setMinimized(bool $minimized)

Set whether the workbook window is minimized.

Parameters

bool $minimized true if workbook window is minimized

bool getAutoFilterDateGrouping()

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

Return Value

bool true if workbook window is minimized

setAutoFilterDateGrouping(bool $autoFilterDateGrouping)

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

Parameters

bool $autoFilterDateGrouping true if workbook window is minimized

int getFirstSheetIndex()

Return the first sheet in the book view.

Return Value

int First sheet in book view

setFirstSheetIndex(int $firstSheetIndex)

Set the first sheet in the book view.

Parameters

int $firstSheetIndex First sheet in book view

Exceptions

Exception if the given value is invalid

string getVisibility()

Return the visibility status of the workbook.

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

Return Value

string Visible status

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

Exceptions

Exception if the given value is invalid

int getTabRatio()

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 Value

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

setTabRatio(int $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

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

Exceptions

Exception if the given value is invalid