class PHPExcel_Worksheet implements PHPExcel_IComparable

PHPExcel_Worksheet

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

Constants

BREAK_NONE

BREAK_ROW

BREAK_COLUMN

SHEETSTATE_VISIBLE

SHEETSTATE_HIDDEN

SHEETSTATE_VERYHIDDEN

Methods

__construct(PHPExcel $pParent = null, string $pTitle = 'Worksheet')

Create a new worksheet

disconnectCells()

Disconnect all cells from this PHPExcel_Worksheet object, typically so that the worksheet object can be unset

__destruct()

Code to execute when this worksheet is unset()

PHPExcel_CachedObjectStorage_xxx
getCellCacheController()

Return the cache controller for the cell collection

static array
getInvalidCharacters()

Get array of invalid characters for sheet title

getCellCollection(boolean $pSorted = true)

Get collection of cells

sortCellCollection()

Sort collection of cells

getRowDimensions()

Get collection of row dimensions

getColumnDimensions()

Get collection of column dimensions

getDrawingCollection()

Get collection of drawings

getChartCollection()

Get collection of charts

addChart(PHPExcel_Chart $pChart = null, int|null $iChartIndex = null)

Add chart

int
getChartCount()

Return the count of charts on this worksheet

getChartByIndex(string $index = null)

Get a chart by its index position

string[]
getChartNames()

Return an array of the names of charts on this worksheet

getChartByName(string $chartName = '')

Get a chart by name

refreshColumnDimensions()

Refresh column dimensions

refreshRowDimensions()

Refresh row dimensions

string
calculateWorksheetDimension()

Calculate worksheet dimension

string
calculateWorksheetDataDimension()

Calculate worksheet data dimension

PHPExcel_Worksheet;
calculateColumnWidths(boolean $calculateMergeCells = false)

Calculate widths for auto-size columns

getParent()

Get parent

rebindParent(PHPExcel $parent)

Re-bind parent

string
getTitle()

Get title

setTitle(string $pValue = 'Worksheet', string $updateFormulaCellReferences = true)

Set title

string
getSheetState()

Get sheet state

setSheetState(string $value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)

Set sheet state

string
getHighestColumn(string $row = null)

Get highest worksheet column

string
getHighestDataColumn(string $row = null)

Get highest worksheet column that contains data

int
getHighestRow(string $column = null)

Get highest worksheet row

string
getHighestDataRow(string $column = null)

Get highest worksheet row that contains data

array
getHighestRowAndColumn()

Get highest worksheet column and highest row that have cell records

setCellValue(string $pCoordinate = 'A1', mixed $pValue = null, bool $returnCell = false)

Set a cell value

setCellValueByColumnAndRow(string $pColumn, string $pRow = 1, mixed $pValue = null, bool $returnCell = false)

Set a cell value by using numeric cell coordinates

setCellValueExplicit(string $pCoordinate = 'A1', mixed $pValue = null, string $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, bool $returnCell = false)

Set a cell value

setCellValueExplicitByColumnAndRow(string $pColumn, string $pRow = 1, mixed $pValue = null, string $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, bool $returnCell = false)

Set a cell value by using numeric cell coordinates

getCell(string $pCoordinate = 'A1', boolean $createIfNotExists = true)

Get cell at a specific coordinate

getCellByColumnAndRow(string $pColumn, string $pRow = 1, boolean $createIfNotExists = true)

Get cell at a specific coordinate by using numeric cell coordinates

boolean
cellExists(string $pCoordinate = 'A1')

Does the cell at a specific coordinate exist?

boolean
cellExistsByColumnAndRow(string $pColumn, string $pRow = 1)

Cell at a specific coordinate by using numeric cell coordinates exists?

getRowDimension($pRow = 1, $create = true)

Get row dimension at a specific row

getColumnDimension($pColumn = 'A', $create = true)

Get column dimension at a specific column

getColumnDimensionByColumn(string $pColumn)

Get column dimension at a specific column by using numeric cell coordinates

getStyles()

Get styles

getDefaultStyle() deprecated

Get default style of workbook.

setDefaultStyle(PHPExcel_Style $pValue) deprecated

Set default style - should only be used by PHPExcel_IReader implementations!

getStyle(string $pCellCoordinate = 'A1')

Get style for cell

getConditionalStyles(string $pCoordinate = 'A1')

Get conditional styles for a cell

boolean
conditionalStylesExists(string $pCoordinate = 'A1')

Do conditional styles exist for this cell?

removeConditionalStyles(string $pCoordinate = 'A1')

Removes conditional styles for a cell

array
getConditionalStylesCollection()

Get collection of conditional styles

setConditionalStyles($pCoordinate = 'A1', $pValue)

Set conditional styles

getStyleByColumnAndRow(int $pColumn, int $pRow = 1, int $pColumn2 = null, int $pRow2 = null)

Get style for cell by using numeric cell coordinates

setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, string $pRange = '') deprecated

Set shared cell style to a range of cells

duplicateStyle(PHPExcel_Style $pCellStyle = null, string $pRange = '')

Duplicate cell style to a range of cells

duplicateConditionalStyle(array $pCellStyle = null, string $pRange = '')

Duplicate conditional style to a range of cells

duplicateStyleArray(array $pStyles = null, string $pRange = '', boolean $pAdvanced = true) deprecated

Duplicate cell style array to a range of cells

setBreak(string $pCell = 'A1', int $pBreak = PHPExcel_Worksheet::BREAK_NONE)

Set break on a cell

setBreakByColumnAndRow(integer $pColumn, integer $pRow = 1, integer $pBreak = PHPExcel_Worksheet::BREAK_NONE)

Set break on a cell by using numeric cell coordinates

array[]
getBreaks()

Get breaks

mergeCells(string $pRange = 'A1:A1')

Set merge on a cell range

mergeCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1)

Set merge on a cell range by using numeric cell coordinates

unmergeCells(string $pRange = 'A1:A1')

Remove merge on a cell range

unmergeCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1)

Remove merge on a cell range by using numeric cell coordinates

array[]
getMergeCells()

Get merge cells array.

setMergeCells(array $pValue = array())

Set merge cells array for the entire sheet. Use instead mergeCells() to merge a single cell range.

protectCells(string $pRange = 'A1', string $pPassword = '', boolean $pAlreadyHashed = false)

Set protection on a cell range

protectCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1, string $pPassword = '', boolean $pAlreadyHashed = false)

Set protection on a cell range by using numeric cell coordinates

unprotectCells(string $pRange = 'A1')

Remove protection on a cell range

unprotectCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1, string $pPassword = '', boolean $pAlreadyHashed = false)

Remove protection on a cell range by using numeric cell coordinates

array[]
getProtectedCells()

Get protected cells

getAutoFilter()

Get Autofilter

setAutoFilter($pValue)

Set AutoFilter

setAutoFilterByColumnAndRow($pColumn1, $pRow1 = 1, $pColumn2, $pRow2 = 1)

Set Autofilter Range by using numeric cell coordinates

removeAutoFilter()

Remove autofilter

string
getFreezePane()

Get Freeze Pane

freezePane(string $pCell = '')

Freeze Pane

freezePaneByColumnAndRow(int $pColumn, int $pRow = 1)

Freeze Pane by using numeric cell coordinates

insertNewRowBefore(int $pBefore = 1, int $pNumRows = 1)

Insert a new row, updating all possible related data

insertNewColumnBefore(int $pBefore = 'A', int $pNumCols = 1)

Insert a new column, updating all possible related data

insertNewColumnBeforeByIndex(int $pBefore, int $pNumCols = 1)

Insert a new column, updating all possible related data

removeRow(int $pRow = 1, int $pNumRows = 1)

Delete a row, updating all possible related data

removeColumn(string $pColumn = 'A', int $pNumCols = 1)

Remove a column, updating all possible related data

removeColumnByIndex(int $pColumn, int $pNumCols = 1)

Remove a column, updating all possible related data

boolean
getShowGridlines()

Show gridlines?

setShowGridlines(boolean $pValue = false)

Set show gridlines

boolean
getPrintGridlines()

Print gridlines?

setPrintGridlines(boolean $pValue = false)

Set print gridlines

boolean
getShowRowColHeaders()

Show row and column headers?

setShowRowColHeaders(boolean $pValue = false)

Set show row and column headers

boolean
getShowSummaryBelow()

Show summary below? (Row/Column outlining)

setShowSummaryBelow(boolean $pValue = true)

Set show summary below

boolean
getShowSummaryRight()

Show summary right? (Row/Column outlining)

setShowSummaryRight(boolean $pValue = true)

Set show summary right

getComments()

Get comments

setComments(array $pValue = array())

Set comments array for the entire sheet.

getComment(string $pCellCoordinate = 'A1')

Get comment for cell

getCommentByColumnAndRow(int $pColumn, int $pRow = 1)

Get comment for cell by using numeric cell coordinates

string
getSelectedCell() deprecated

Get selected cell

string
getActiveCell()

Get active cell

string
getSelectedCells()

Get selected cells

setSelectedCell(string $pCoordinate = 'A1')

Selected cell

setSelectedCells(string $pCoordinate = 'A1')

Select a range of cells.

setSelectedCellByColumnAndRow(int $pColumn, int $pRow = 1)

Selected cell by using numeric cell coordinates

boolean
getRightToLeft()

Get right-to-left

setRightToLeft(boolean $value = false)

Set right-to-left

fromArray(array $source = null, mixed $nullValue = null, string $startCell = 'A1', boolean $strictNullComparison = false)

Fill worksheet from values in array

array
rangeToArray(string $pRange = 'A1', mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from a range of cells

array
namedRangeToArray(string $pNamedRange = '', mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from a range of cells

array
toArray(mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from worksheet

getRowIterator(integer $startRow = 1, integer $endRow = null)

Get row iterator

getColumnIterator(string $startColumn = 'A', string $endColumn = null)

Get column iterator

garbageCollect()

Run PHPExcel garabage collector.

string
getHashCode()

Get hash code

static mixed
extractSheetTitle(string $pRange, bool $returnRange = false)

Extract worksheet title from range.

getHyperlink(string $pCellCoordinate = 'A1')

Get hyperlink

setHyperlink(string $pCellCoordinate = 'A1', PHPExcel_Cell_Hyperlink $pHyperlink = null)

Set hyperlnk

boolean
hyperlinkExists(string $pCoordinate = 'A1')

Hyperlink at a specific coordinate exists?

getHyperlinkCollection()

Get collection of hyperlinks

getDataValidation(string $pCellCoordinate = 'A1')

Get data validation

setDataValidation(string $pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null)

Set data validation

boolean
dataValidationExists(string $pCoordinate = 'A1')

Data validation at a specific coordinate exists?

getDataValidationCollection()

Get collection of data validations

string
shrinkRangeToFit(string $range)

Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet

resetTabColor()

Reset tab color

boolean
isTabColorSet()

Tab color set?

copy()

Copy worksheet (!= clone!)

__clone()

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

objWorksheet
setCodeName(null|string $pValue = null)

Define the code name of the sheet

null|string
getCodeName()

Return the code name of the sheet

boolean
hasCodeName()

Sheet has a code name ?

Details

at line 342
__construct(PHPExcel $pParent = null, string $pTitle = 'Worksheet')

Create a new worksheet

Parameters

PHPExcel $pParent
string $pTitle

at line 379
disconnectCells()

Disconnect all cells from this PHPExcel_Worksheet object, typically so that the worksheet object can be unset

at line 393
__destruct()

Code to execute when this worksheet is unset()

at line 405
PHPExcel_CachedObjectStorage_xxx getCellCacheController()

Return the cache controller for the cell collection

Return Value

PHPExcel_CachedObjectStorage_xxx

at line 416
static array getInvalidCharacters()

Get array of invalid characters for sheet title

Return Value

array

at line 477
PHPExcel_Cell[] getCellCollection(boolean $pSorted = true)

Get collection of cells

Parameters

boolean $pSorted Also sort the cell collection?

Return Value

PHPExcel_Cell[]

at line 494
PHPExcel_Worksheet sortCellCollection()

Sort collection of cells

Return Value

PHPExcel_Worksheet

at line 507
PHPExcel_Worksheet_RowDimension[] getRowDimensions()

Get collection of row dimensions

at line 517
PHPExcel_Worksheet_RowDimension getDefaultRowDimension()

Get default row dimension

at line 527
PHPExcel_Worksheet_ColumnDimension[] getColumnDimensions()

Get collection of column dimensions

at line 537
PHPExcel_Worksheet_ColumnDimension getDefaultColumnDimension()

Get default column dimension

at line 547
PHPExcel_Worksheet_BaseDrawing[] getDrawingCollection()

Get collection of drawings

at line 557
PHPExcel_Chart[] getChartCollection()

Get collection of charts

Return Value

PHPExcel_Chart[]

at line 569
PHPExcel_Chart addChart(PHPExcel_Chart $pChart = null, int|null $iChartIndex = null)

Add chart

Parameters

PHPExcel_Chart $pChart
int|null $iChartIndex Index where chart should go (0,1,..., or null for last)

Return Value

PHPExcel_Chart

at line 587
int getChartCount()

Return the count of charts on this worksheet

Return Value

int The number of charts

at line 599
false|PHPExcel_Chart getChartByIndex(string $index = null)

Get a chart by its index position

Parameters

string $index Chart index position

Return Value

false|PHPExcel_Chart

Exceptions

PHPExcel_Exception

at line 621
string[] getChartNames()

Return an array of the names of charts on this worksheet

Return Value

string[] The names of charts

Exceptions

PHPExcel_Exception

at line 637
false|PHPExcel_Chart getChartByName(string $chartName = '')

Get a chart by name

Parameters

string $chartName Chart name

Return Value

false|PHPExcel_Chart

Exceptions

PHPExcel_Exception

at line 656
PHPExcel_Worksheet refreshColumnDimensions()

Refresh column dimensions

Return Value

PHPExcel_Worksheet

at line 675
PHPExcel_Worksheet refreshRowDimensions()

Refresh row dimensions

Return Value

PHPExcel_Worksheet

at line 694
string calculateWorksheetDimension()

Calculate worksheet dimension

Return Value

string String containing the dimension of this worksheet

at line 705
string calculateWorksheetDataDimension()

Calculate worksheet data dimension

Return Value

string String containing the dimension of this worksheet that actually contain data

at line 717
PHPExcel_Worksheet; calculateColumnWidths(boolean $calculateMergeCells = false)

Calculate widths for auto-size columns

Parameters

boolean $calculateMergeCells Calculate merge cell width

Return Value

PHPExcel_Worksheet;

at line 780
PHPExcel getParent()

Get parent

Return Value

PHPExcel

at line 791
PHPExcel_Worksheet rebindParent(PHPExcel $parent)

Re-bind parent

Parameters

PHPExcel $parent

Return Value

PHPExcel_Worksheet

at line 813
string getTitle()

Get title

Return Value

string

at line 829
PHPExcel_Worksheet setTitle(string $pValue = 'Worksheet', string $updateFormulaCellReferences = true)

Set title

Parameters

string $pValue String containing the dimension of this worksheet
string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should be updated to reflect the new sheet name. This should be left as the default true, unless you are certain that no formula cells on any worksheet contain references to this worksheet

Return Value

PHPExcel_Worksheet

at line 891
string getSheetState()

Get sheet state

Return Value

string Sheet state (visible, hidden, veryHidden)

at line 902
PHPExcel_Worksheet setSheetState(string $value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)

Set sheet state

Parameters

string $value Sheet state (visible, hidden, veryHidden)

Return Value

PHPExcel_Worksheet

at line 913
PHPExcel_Worksheet_PageSetup getPageSetup()

Get page setup

at line 924
PHPExcel_Worksheet setPageSetup(PHPExcel_Worksheet_PageSetup $pValue)

Set page setup

Parameters

PHPExcel_Worksheet_PageSetup $pValue

Return Value

PHPExcel_Worksheet

at line 935
PHPExcel_Worksheet_PageMargins getPageMargins()

Get page margins

at line 946
PHPExcel_Worksheet setPageMargins(PHPExcel_Worksheet_PageMargins $pValue)

Set page margins

Parameters

PHPExcel_Worksheet_PageMargins $pValue

Return Value

PHPExcel_Worksheet

at line 957
PHPExcel_Worksheet_HeaderFooter getHeaderFooter()

Get page header/footer

at line 968
PHPExcel_Worksheet setHeaderFooter(PHPExcel_Worksheet_HeaderFooter $pValue)

Set page header/footer

Parameters

PHPExcel_Worksheet_HeaderFooter $pValue

Return Value

PHPExcel_Worksheet

at line 979
PHPExcel_Worksheet_SheetView getSheetView()

Get sheet view

at line 990
PHPExcel_Worksheet setSheetView(PHPExcel_Worksheet_SheetView $pValue)

Set sheet view

Parameters

PHPExcel_Worksheet_SheetView $pValue

Return Value

PHPExcel_Worksheet

at line 1001
PHPExcel_Worksheet_Protection getProtection()

Get Protection

at line 1012
PHPExcel_Worksheet setProtection(PHPExcel_Worksheet_Protection $pValue)

Set Protection

Parameters

PHPExcel_Worksheet_Protection $pValue

Return Value

PHPExcel_Worksheet

at line 1027
string getHighestColumn(string $row = null)

Get highest worksheet column

Parameters

string $row Return the data highest column for the specified row, or the highest column of any row if no row number is passed

Return Value

string Highest column name

at line 1042
string getHighestDataColumn(string $row = null)

Get highest worksheet column that contains data

Parameters

string $row Return the highest data column for the specified row, or the highest data column of any row if no row number is passed

Return Value

string Highest column name that contains data

at line 1054
int getHighestRow(string $column = null)

Get highest worksheet row

Parameters

string $column Return the highest data row for the specified column, or the highest row of any column if no column letter is passed

Return Value

int Highest row number

at line 1069
string getHighestDataRow(string $column = null)

Get highest worksheet row that contains data

Parameters

string $column Return the highest data row for the specified column, or the highest data row of any column if no column letter is passed

Return Value

string Highest row number that contains data

at line 1079
array getHighestRowAndColumn()

Get highest worksheet column and highest row that have cell records

Return Value

array Highest column name and highest row number

at line 1092
PHPExcel_Worksheet|PHPExcel_Cell setCellValue(string $pCoordinate = 'A1', mixed $pValue = null, bool $returnCell = false)

Set a cell value

Parameters

string $pCoordinate Coordinate of the cell
mixed $pValue Value of the cell
bool $returnCell Return the worksheet (false, default) or the cell (true)

Return Value

PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified

at line 1107
PHPExcel_Worksheet|PHPExcel_Cell setCellValueByColumnAndRow(string $pColumn, string $pRow = 1, mixed $pValue = null, bool $returnCell = false)

Set a cell value by using numeric cell coordinates

Parameters

string $pColumn Numeric column coordinate of the cell (A = 0)
string $pRow Numeric row coordinate of the cell
mixed $pValue Value of the cell
bool $returnCell Return the worksheet (false, default) or the cell (true)

Return Value

PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified

at line 1122
PHPExcel_Worksheet|PHPExcel_Cell setCellValueExplicit(string $pCoordinate = 'A1', mixed $pValue = null, string $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, bool $returnCell = false)

Set a cell value

Parameters

string $pCoordinate Coordinate of the cell
mixed $pValue Value of the cell
string $pDataType Explicit data type
bool $returnCell Return the worksheet (false, default) or the cell (true)

Return Value

PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified

at line 1139
PHPExcel_Worksheet|PHPExcel_Cell setCellValueExplicitByColumnAndRow(string $pColumn, string $pRow = 1, mixed $pValue = null, string $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, bool $returnCell = false)

Set a cell value by using numeric cell coordinates

Parameters

string $pColumn Numeric column coordinate of the cell
string $pRow Numeric row coordinate of the cell
mixed $pValue Value of the cell
string $pDataType Explicit data type
bool $returnCell Return the worksheet (false, default) or the cell (true)

Return Value

PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified

at line 1154
null|PHPExcel_Cell getCell(string $pCoordinate = 'A1', boolean $createIfNotExists = true)

Get cell at a specific coordinate

Parameters

string $pCoordinate Coordinate of the cell
boolean $createIfNotExists Flag indicating whether a new cell should be created if it doesn't already exist, or a null should be returned instead

Return Value

null|PHPExcel_Cell Cell that was found/created or null

Exceptions

PHPExcel_Exception

at line 1199
null|PHPExcel_Cell getCellByColumnAndRow(string $pColumn, string $pRow = 1, boolean $createIfNotExists = true)

Get cell at a specific coordinate by using numeric cell coordinates

Parameters

string $pColumn Numeric column coordinate of the cell (starting from 0)
string $pRow Numeric row coordinate of the cell
boolean $createIfNotExists Flag indicating whether a new cell should be created if it doesn't already exist, or a null should be returned instead

Return Value

null|PHPExcel_Cell Cell that was found/created or null

at line 1256
boolean cellExists(string $pCoordinate = 'A1')

Does the cell at a specific coordinate exist?

Parameters

string $pCoordinate Coordinate of the cell

Return Value

boolean

Exceptions

PHPExcel_Exception

at line 1305
boolean cellExistsByColumnAndRow(string $pColumn, string $pRow = 1)

Cell at a specific coordinate by using numeric cell coordinates exists?

Parameters

string $pColumn Numeric column coordinate of the cell
string $pRow Numeric row coordinate of the cell

Return Value

boolean

at line 1316
PHPExcel_Worksheet_RowDimension getRowDimension($pRow = 1, $create = true)

Get row dimension at a specific row

Parameters

$pRow
$create

Return Value

PHPExcel_Worksheet_RowDimension

at line 1339
PHPExcel_Worksheet_ColumnDimension getColumnDimension($pColumn = 'A', $create = true)

Get column dimension at a specific column

Parameters

$pColumn
$create

Return Value

PHPExcel_Worksheet_ColumnDimension

at line 1364
PHPExcel_Worksheet_ColumnDimension getColumnDimensionByColumn(string $pColumn)

Get column dimension at a specific column by using numeric cell coordinates

Parameters

string $pColumn Numeric column coordinate of the cell

Return Value

PHPExcel_Worksheet_ColumnDimension

at line 1374
PHPExcel_Style[] getStyles()

Get styles

Return Value

PHPExcel_Style[]

at line 1386
PHPExcel_Style getDefaultStyle() deprecated

deprecated

Get default style of workbook.

Return Value

PHPExcel_Style

Exceptions

PHPExcel_Exception

at line 1399
PHPExcel_Worksheet setDefaultStyle(PHPExcel_Style $pValue) deprecated

deprecated

Set default style - should only be used by PHPExcel_IReader implementations!

Parameters

PHPExcel_Style $pValue

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1417
PHPExcel_Style getStyle(string $pCellCoordinate = 'A1')

Get style for cell

Parameters

string $pCellCoordinate Cell coordinate (or range) to get style for

Return Value

PHPExcel_Style

Exceptions

PHPExcel_Exception

at line 1434
PHPExcel_Style_Conditional[] getConditionalStyles(string $pCoordinate = 'A1')

Get conditional styles for a cell

Parameters

string $pCoordinate

Return Value

PHPExcel_Style_Conditional[]

at line 1449
boolean conditionalStylesExists(string $pCoordinate = 'A1')

Do conditional styles exist for this cell?

Parameters

string $pCoordinate

Return Value

boolean

at line 1463
PHPExcel_Worksheet removeConditionalStyles(string $pCoordinate = 'A1')

Removes conditional styles for a cell

Parameters

string $pCoordinate

Return Value

PHPExcel_Worksheet

at line 1474
array getConditionalStylesCollection()

Get collection of conditional styles

Return Value

array

at line 1486
PHPExcel_Worksheet setConditionalStyles($pCoordinate = 'A1', $pValue)

Set conditional styles

Parameters

$pCoordinate string E.g. 'A1'
$pValue PHPExcelStyleConditional[]

Return Value

PHPExcel_Worksheet

at line 1501
PHPExcel_Style getStyleByColumnAndRow(int $pColumn, int $pRow = 1, int $pColumn2 = null, int $pRow2 = null)

Get style for cell by using numeric cell coordinates

Parameters

int $pColumn Numeric column coordinate of the cell
int $pRow Numeric row coordinate of the cell
int $pColumn2 pColumn2 Numeric column coordinate of the range cell
int $pRow2 pRow2 Numeric row coordinate of the range cell

Return Value

PHPExcel_Style

at line 1522
PHPExcel_Worksheet setSharedStyle(PHPExcel_Style $pSharedCellStyle = null, string $pRange = '') deprecated

deprecated

Set shared cell style to a range of cells

Please note that this will overwrite existing cell styles for cells in range!

Parameters

PHPExcel_Style $pSharedCellStyle Cell style to share
string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1538
PHPExcel_Worksheet duplicateStyle(PHPExcel_Style $pCellStyle = null, string $pRange = '')

Duplicate cell style to a range of cells

Please note that this will overwrite existing cell styles for cells in range!

Parameters

PHPExcel_Style $pCellStyle Cell style to duplicate
string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1584
PHPExcel_Worksheet duplicateConditionalStyle(array $pCellStyle = null, string $pRange = '')

Duplicate conditional style to a range of cells

Please note that this will overwrite existing cell styles for cells in range!

Parameters

array $pCellStyle of PHPExcelStyleConditional $pCellStyle Cell style to duplicate
string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1626
PHPExcel_Worksheet duplicateStyleArray(array $pStyles = null, string $pRange = '', boolean $pAdvanced = true) deprecated

deprecated

Duplicate cell style array to a range of cells

Please note that this will overwrite existing cell styles for cells in range, if they are in the styles array. For example, if you decide to set a range of cells to font bold, only include font bold in the styles array.

Parameters

array $pStyles Array containing style information
string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
boolean $pAdvanced Advanced mode for setting borders.

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1640
PHPExcel_Worksheet setBreak(string $pCell = 'A1', int $pBreak = PHPExcel_Worksheet::BREAK_NONE)

Set break on a cell

Parameters

string $pCell Cell coordinate (e.g. A1)
int $pBreak Break type (type of PHPExcelWorksheet::BREAK*)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1668
PHPExcel_Worksheet setBreakByColumnAndRow(integer $pColumn, integer $pRow = 1, integer $pBreak = PHPExcel_Worksheet::BREAK_NONE)

Set break on a cell by using numeric cell coordinates

Parameters

integer $pColumn Numeric column coordinate of the cell
integer $pRow Numeric row coordinate of the cell
integer $pBreak Break type (type of PHPExcelWorksheet::BREAK*)

Return Value

PHPExcel_Worksheet

at line 1678
array[] getBreaks()

Get breaks

Return Value

array[]

at line 1690
PHPExcel_Worksheet mergeCells(string $pRange = 'A1:A1')

Set merge on a cell range

Parameters

string $pRange Cell range (e.g. A1:E1)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1733
PHPExcel_Worksheet mergeCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1)

Set merge on a cell range by using numeric cell coordinates

Parameters

int $pColumn1 Numeric column coordinate of the first cell
int $pRow1 Numeric row coordinate of the first cell
int $pColumn2 Numeric column coordinate of the last cell
int $pRow2 Numeric row coordinate of the last cell

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1746
PHPExcel_Worksheet unmergeCells(string $pRange = 'A1:A1')

Remove merge on a cell range

Parameters

string $pRange Cell range (e.g. A1:E1)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1774
PHPExcel_Worksheet unmergeCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1)

Remove merge on a cell range by using numeric cell coordinates

Parameters

int $pColumn1 Numeric column coordinate of the first cell
int $pRow1 Numeric row coordinate of the first cell
int $pColumn2 Numeric column coordinate of the last cell
int $pRow2 Numeric row coordinate of the last cell

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1785
array[] getMergeCells()

Get merge cells array.

Return Value

array[]

at line 1796
setMergeCells(array $pValue = array())

Set merge cells array for the entire sheet. Use instead mergeCells() to merge a single cell range.

Parameters

array $pValue

at line 1811
PHPExcel_Worksheet protectCells(string $pRange = 'A1', string $pPassword = '', boolean $pAlreadyHashed = false)

Set protection on a cell range

Parameters

string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1)
string $pPassword Password to unlock the protection
boolean $pAlreadyHashed If the password has already been hashed, set this to true

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1836
PHPExcel_Worksheet protectCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1, string $pPassword = '', boolean $pAlreadyHashed = false)

Set protection on a cell range by using numeric cell coordinates

Parameters

int $pColumn1 Numeric column coordinate of the first cell
int $pRow1 Numeric row coordinate of the first cell
int $pColumn2 Numeric column coordinate of the last cell
int $pRow2 Numeric row coordinate of the last cell
string $pPassword Password to unlock the protection
boolean $pAlreadyHashed If the password has already been hashed, set this to true

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1849
PHPExcel_Worksheet unprotectCells(string $pRange = 'A1')

Remove protection on a cell range

Parameters

string $pRange Cell (e.g. A1) or cell range (e.g. A1:E1)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1874
PHPExcel_Worksheet unprotectCellsByColumnAndRow(int $pColumn1, int $pRow1 = 1, int $pColumn2, int $pRow2 = 1, string $pPassword = '', boolean $pAlreadyHashed = false)

Remove protection on a cell range by using numeric cell coordinates

Parameters

int $pColumn1 Numeric column coordinate of the first cell
int $pRow1 Numeric row coordinate of the first cell
int $pColumn2 Numeric column coordinate of the last cell
int $pRow2 Numeric row coordinate of the last cell
string $pPassword Password to unlock the protection
boolean $pAlreadyHashed If the password has already been hashed, set this to true

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1885
array[] getProtectedCells()

Get protected cells

Return Value

array[]

at line 1895
getAutoFilter()

Get Autofilter

@return PHPExcelWorksheetAutoFilter

at line 1908
setAutoFilter($pValue)

Set AutoFilter

@param PHPExcelWorksheetAutoFilter|string $pValue A simple string containing a Cell range like 'A1:E10' is permitted for backward compatibility

Parameters

$pValue

Exceptions

PHPExcel_Exception @return PHPExcel_Worksheet

at line 1929
setAutoFilterByColumnAndRow($pColumn1, $pRow1 = 1, $pColumn2, $pRow2 = 1)

Set Autofilter Range by using numeric cell coordinates

@param integer $pColumn1 Numeric column coordinate of the first cell

Parameters

$pColumn1
$pRow1
$pColumn2
$pRow2

at line 1943
PHPExcel_Worksheet removeAutoFilter()

Remove autofilter

Return Value

PHPExcel_Worksheet

at line 1954
string getFreezePane()

Get Freeze Pane

Return Value

string

at line 1971
PHPExcel_Worksheet freezePane(string $pCell = '')

Freeze Pane

Parameters

string $pCell Cell (i.e. A2) Examples: A2 will freeze the rows above cell A2 (i.e row 1) B1 will freeze the columns to the left of cell B1 (i.e column A) B2 will freeze the rows above and to the left of cell A2 (i.e row 1 and column A)

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 1991
PHPExcel_Worksheet freezePaneByColumnAndRow(int $pColumn, int $pRow = 1)

Freeze Pane by using numeric cell coordinates

Parameters

int $pColumn Numeric column coordinate of the cell
int $pRow Numeric row coordinate of the cell

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2001
PHPExcel_Worksheet unfreezePane()

Unfreeze Pane

Return Value

PHPExcel_Worksheet

at line 2014
PHPExcel_Worksheet insertNewRowBefore(int $pBefore = 1, int $pNumRows = 1)

Insert a new row, updating all possible related data

Parameters

int $pBefore Insert before this one
int $pNumRows Number of rows to insert

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2033
PHPExcel_Worksheet insertNewColumnBefore(int $pBefore = 'A', int $pNumCols = 1)

Insert a new column, updating all possible related data

Parameters

int $pBefore Insert before this one
int $pNumCols Number of columns to insert

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2052
PHPExcel_Worksheet insertNewColumnBeforeByIndex(int $pBefore, int $pNumCols = 1)

Insert a new column, updating all possible related data

Parameters

int $pBefore Insert before this one (numeric column coordinate of the cell)
int $pNumCols Number of columns to insert

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2069
PHPExcel_Worksheet removeRow(int $pRow = 1, int $pNumRows = 1)

Delete a row, updating all possible related data

Parameters

int $pRow Remove starting with this one
int $pNumRows Number of rows to remove

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2093
PHPExcel_Worksheet removeColumn(string $pColumn = 'A', int $pNumCols = 1)

Remove a column, updating all possible related data

Parameters

string $pColumn Remove starting with this one
int $pNumCols Number of columns to remove

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2118
PHPExcel_Worksheet removeColumnByIndex(int $pColumn, int $pNumCols = 1)

Remove a column, updating all possible related data

Parameters

int $pColumn Remove starting with this one (numeric column coordinate of the cell)
int $pNumCols Number of columns to remove

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2132
boolean getShowGridlines()

Show gridlines?

Return Value

boolean

at line 2143
PHPExcel_Worksheet setShowGridlines(boolean $pValue = false)

Set show gridlines

Parameters

boolean $pValue Show gridlines (true/false)

Return Value

PHPExcel_Worksheet

at line 2154
boolean getPrintGridlines()

Print gridlines?

Return Value

boolean

at line 2165
PHPExcel_Worksheet setPrintGridlines(boolean $pValue = false)

Set print gridlines

Parameters

boolean $pValue Print gridlines (true/false)

Return Value

PHPExcel_Worksheet

at line 2176
boolean getShowRowColHeaders()

Show row and column headers?

Return Value

boolean

at line 2187
PHPExcel_Worksheet setShowRowColHeaders(boolean $pValue = false)

Set show row and column headers

Parameters

boolean $pValue Show row and column headers (true/false)

Return Value

PHPExcel_Worksheet

at line 2198
boolean getShowSummaryBelow()

Show summary below? (Row/Column outlining)

Return Value

boolean

at line 2209
PHPExcel_Worksheet setShowSummaryBelow(boolean $pValue = true)

Set show summary below

Parameters

boolean $pValue Show summary below (true/false)

Return Value

PHPExcel_Worksheet

at line 2220
boolean getShowSummaryRight()

Show summary right? (Row/Column outlining)

Return Value

boolean

at line 2231
PHPExcel_Worksheet setShowSummaryRight(boolean $pValue = true)

Set show summary right

Parameters

boolean $pValue Show summary right (true/false)

Return Value

PHPExcel_Worksheet

at line 2242
PHPExcel_Comment[] getComments()

Get comments

Return Value

PHPExcel_Comment[]

at line 2253
PHPExcel_Worksheet setComments(array $pValue = array())

Set comments array for the entire sheet.

Parameters

array $pValue of PHPExcel_Comment

Return Value

PHPExcel_Worksheet

at line 2267
PHPExcel_Comment getComment(string $pCellCoordinate = 'A1')

Get comment for cell

Parameters

string $pCellCoordinate Cell coordinate to get comment for

Return Value

PHPExcel_Comment

Exceptions

PHPExcel_Exception

at line 2298
PHPExcel_Comment getCommentByColumnAndRow(int $pColumn, int $pRow = 1)

Get comment for cell by using numeric cell coordinates

Parameters

int $pColumn Numeric column coordinate of the cell
int $pRow Numeric row coordinate of the cell

Return Value

PHPExcel_Comment

at line 2309
string getSelectedCell() deprecated

deprecated

Get selected cell

Return Value

string

at line 2319
string getActiveCell()

Get active cell

Return Value

string Example: 'A1'

at line 2329
string getSelectedCells()

Get selected cells

Return Value

string

at line 2340
PHPExcel_Worksheet setSelectedCell(string $pCoordinate = 'A1')

Selected cell

Parameters

string $pCoordinate Cell (i.e. A1)

Return Value

PHPExcel_Worksheet

at line 2352
PHPExcel_Worksheet setSelectedCells(string $pCoordinate = 'A1')

Select a range of cells.

Parameters

string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6'

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2387
PHPExcel_Worksheet setSelectedCellByColumnAndRow(int $pColumn, int $pRow = 1)

Selected cell by using numeric cell coordinates

Parameters

int $pColumn Numeric column coordinate of the cell
int $pRow Numeric row coordinate of the cell

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2397
boolean getRightToLeft()

Get right-to-left

Return Value

boolean

at line 2408
PHPExcel_Worksheet setRightToLeft(boolean $value = false)

Set right-to-left

Parameters

boolean $value Right-to-left true/false

Return Value

PHPExcel_Worksheet

at line 2424
PHPExcel_Worksheet fromArray(array $source = null, mixed $nullValue = null, string $startCell = 'A1', boolean $strictNullComparison = false)

Fill worksheet from values in array

Parameters

array $source Source array
mixed $nullValue Value in source array that stands for blank cell
string $startCell Insert array starting from this cell address as the top left coordinate
boolean $strictNullComparison Apply strict comparison when testing for null values in the array

Return Value

PHPExcel_Worksheet

Exceptions

PHPExcel_Exception

at line 2471
array rangeToArray(string $pRange = 'A1', mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from a range of cells

Parameters

string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
mixed $nullValue Value returned in the array entry if a cell doesn't exist
boolean $calculateFormulas Should formulas be calculated?
boolean $formatData Should formatting be applied to cell values?
boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return Value

array

at line 2542
array namedRangeToArray(string $pNamedRange = '', mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from a range of cells

Parameters

string $pNamedRange Name of the Named Range
mixed $nullValue Value returned in the array entry if a cell doesn't exist
boolean $calculateFormulas Should formulas be calculated?
boolean $formatData Should formatting be applied to cell values?
boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return Value

array

Exceptions

PHPExcel_Exception

at line 2566
array toArray(mixed $nullValue = null, boolean $calculateFormulas = true, boolean $formatData = true, boolean $returnCellRef = false)

Create array from worksheet

Parameters

mixed $nullValue Value returned in the array entry if a cell doesn't exist
boolean $calculateFormulas Should formulas be calculated?
boolean $formatData Should formatting be applied to cell values?
boolean $returnCellRef False - Return a simple array of rows and columns indexed by number counting from zero True - Return rows and columns indexed by their actual row and column IDs

Return Value

array

at line 2586
PHPExcel_Worksheet_RowIterator getRowIterator(integer $startRow = 1, integer $endRow = null)

Get row iterator

Parameters

integer $startRow The row number at which to start iterating
integer $endRow The row number at which to stop iterating

Return Value

PHPExcel_Worksheet_RowIterator

at line 2599
PHPExcel_Worksheet_ColumnIterator getColumnIterator(string $startColumn = 'A', string $endColumn = null)

Get column iterator

Parameters

string $startColumn The column address at which to start iterating
string $endColumn The column address at which to stop iterating

Return Value

PHPExcel_Worksheet_ColumnIterator

at line 2609
PHPExcel_Worksheet garbageCollect()

Run PHPExcel garabage collector.

Return Value

PHPExcel_Worksheet

at line 2654
string getHashCode()

Get hash code

Return Value

string Hash code

at line 2673
static mixed extractSheetTitle(string $pRange, bool $returnRange = false)

Extract worksheet title from range.

Example: extractSheetTitle("testSheet!A1") ==> 'A1' Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1');

Parameters

string $pRange Range to extract title from
bool $returnRange Return range? (see example)

Return Value

mixed

Get hyperlink

Parameters

string $pCellCoordinate Cell coordinate to get hyperlink for

Set hyperlnk

Parameters

string $pCellCoordinate Cell coordinate to insert hyperlink
PHPExcel_Cell_Hyperlink $pHyperlink

Return Value

PHPExcel_Worksheet

at line 2727
boolean hyperlinkExists(string $pCoordinate = 'A1')

Hyperlink at a specific coordinate exists?

Parameters

string $pCoordinate

Return Value

boolean

at line 2737
PHPExcel_Cell_Hyperlink[] getHyperlinkCollection()

Get collection of hyperlinks

Return Value

PHPExcel_Cell_Hyperlink[]

at line 2747
getDataValidation(string $pCellCoordinate = 'A1')

Get data validation

Parameters

string $pCellCoordinate Cell coordinate to get data validation for

at line 2766
PHPExcel_Worksheet setDataValidation(string $pCellCoordinate = 'A1', PHPExcel_Cell_DataValidation $pDataValidation = null)

Set data validation

Parameters

string $pCellCoordinate Cell coordinate to insert data validation
PHPExcel_Cell_DataValidation $pDataValidation

Return Value

PHPExcel_Worksheet

at line 2782
boolean dataValidationExists(string $pCoordinate = 'A1')

Data validation at a specific coordinate exists?

Parameters

string $pCoordinate

Return Value

boolean

at line 2792
PHPExcel_Cell_DataValidation[] getDataValidationCollection()

Get collection of data validations

at line 2803
string shrinkRangeToFit(string $range)

Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet

Parameters

string $range

Return Value

string Adjusted range value

at line 2838
PHPExcel_Style_Color getTabColor()

Get tab color

Return Value

PHPExcel_Style_Color

at line 2851
PHPExcel_Worksheet resetTabColor()

Reset tab color

Return Value

PHPExcel_Worksheet

at line 2864
boolean isTabColorSet()

Tab color set?

Return Value

boolean

at line 2874
PHPExcel_Worksheet copy()

Copy worksheet (!= clone!)

Return Value

PHPExcel_Worksheet

at line 2884
__clone()

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

at line 2916
objWorksheet setCodeName(null|string $pValue = null)

Define the code name of the sheet

Parameters

null|string $pValue Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)

Return Value

objWorksheet

Exceptions

PHPExcel_Exception

at line 2965
null|string getCodeName()

Return the code name of the sheet

Return Value

null|string

at line 2973
boolean hasCodeName()

Sheet has a code name ?

Return Value

boolean