Table
in package
implements
Stringable
Table of Contents
Interfaces
- Stringable
Properties
- $allowFilter : bool
- Table allow filter.
- $autoFilter : AutoFilter
- Table AutoFilter.
- $columns : array<string|int, Column>
- Table Column.
- $name : string
- Table Name.
- $range : string
- Table Range.
- $showHeaderRow : bool
- Show Header Row.
- $showTotalsRow : bool
- Show Totals Row.
- $style : TableStyle
- Table Style.
- $workSheet : Worksheet|null
- Table Worksheet.
Methods
- __clone() : mixed
- Implement PHP __clone to create a deep clone, not just a shallow copy.
- __construct() : mixed
- Create a new Table.
- __destruct() : mixed
- Code to execute when this table is unset().
- __toString() : string
- toString method replicates previous behavior by returning the range if object is referenced as a property of its worksheet.
- clearColumn() : self
- Clear a specified Table Column.
- getAllowFilter() : bool
- Get allow filter.
- getAutoFilter() : AutoFilter
- Get AutoFilter.
- getColumn() : Column
- Get a specified Table Column.
- getColumnByOffset() : Column
- Get a specified Table Column by it's offset.
- getColumnOffset() : int
- Get a specified Table Column Offset within the defined Table range.
- getColumns() : array<string|int, Column>
- Get all Table Columns.
- getName() : string
- Get Table name.
- getRange() : string
- Get Table Range.
- getShowHeaderRow() : bool
- Get show Header Row.
- getShowTotalsRow() : bool
- Get show Totals Row.
- getStyle() : TableStyle
- Get table Style.
- getWorksheet() : Worksheet|null
- Get Table's Worksheet.
- isColumnInRange() : int
- Validate that the specified column is in the Table range.
- setAllowFilter() : self
- Set show Autofiltering.
- setAutoFilter() : self
- Set AutoFilter.
- setColumn() : self
- Set Table.
- setName() : self
- Set Table name.
- setRange() : self
- Set Table Cell Range.
- setRangeToMaxRow() : self
- Set Table Cell Range to max row.
- setShowHeaderRow() : self
- Set show Header Row.
- setShowTotalsRow() : self
- Set show Totals Row.
- setStyle() : self
- Set table Style.
- setWorksheet() : self
- Set Table's Worksheet.
- shiftColumn() : self
- Shift an Table Column Rule to a different column.
- checkForDuplicateTableNames() : void
- updateStructuredReferences() : void
- updateStructuredReferencesInCells() : void
- updateStructuredReferencesInNamedFormulae() : void
Properties
$allowFilter
Table allow filter.
private
bool
$allowFilter
= true
$autoFilter
Table AutoFilter.
private
AutoFilter
$autoFilter
$columns
Table Column.
private
array<string|int, Column>
$columns
= []
$name
Table Name.
private
string
$name
$range
Table Range.
private
string
$range
= ''
$showHeaderRow
Show Header Row.
private
bool
$showHeaderRow
= true
$showTotalsRow
Show Totals Row.
private
bool
$showTotalsRow
= false
$style
Table Style.
private
TableStyle
$style
$workSheet
Table Worksheet.
private
Worksheet|null
$workSheet
= null
Methods
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
public
__clone() : mixed
__construct()
Create a new Table.
public
__construct([AddressRange<string|int, CellAddress>|array{0: int, 1: int, 2: int, 3: int}|array{0: int, 1: int}|string $range = '' ][, string $name = '' ]) : mixed
Parameters
- $range : AddressRange<string|int, CellAddress>|array{0: int, 1: int, 2: int, 3: int}|array{0: int, 1: int}|string = ''
-
A simple string containing a Cell range like 'A1:E10' is permitted or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), or an AddressRange object.
- $name : string = ''
-
(e.g. Table1)
__destruct()
Code to execute when this table is unset().
public
__destruct() : mixed
__toString()
toString method replicates previous behavior by returning the range if object is referenced as a property of its worksheet.
public
__toString() : string
Return values
stringclearColumn()
Clear a specified Table Column.
public
clearColumn(string $column) : self
Parameters
- $column : string
-
Column name (e.g. A)
Return values
selfgetAllowFilter()
Get allow filter.
public
getAllowFilter() : bool
If false, autofiltering is disabled for the table, if true it is enabled.
Return values
boolgetAutoFilter()
Get AutoFilter.
public
getAutoFilter() : AutoFilter
Return values
AutoFiltergetColumn()
Get a specified Table Column.
public
getColumn(string $column) : Column
Parameters
- $column : string
-
Column name (e.g. A)
Return values
ColumngetColumnByOffset()
Get a specified Table Column by it's offset.
public
getColumnByOffset(int $columnOffset) : Column
Parameters
- $columnOffset : int
-
Column offset within range (starting from 0)
Return values
ColumngetColumnOffset()
Get a specified Table Column Offset within the defined Table range.
public
getColumnOffset(string $column) : int
Parameters
- $column : string
-
Column name (e.g. A)
Return values
int —The offset of the specified column within the table range
getColumns()
Get all Table Columns.
public
getColumns() : array<string|int, Column>
Return values
array<string|int, Column>getName()
Get Table name.
public
getName() : string
Return values
stringgetRange()
Get Table Range.
public
getRange() : string
Return values
stringgetShowHeaderRow()
Get show Header Row.
public
getShowHeaderRow() : bool
Return values
boolgetShowTotalsRow()
Get show Totals Row.
public
getShowTotalsRow() : bool
Return values
boolgetStyle()
Get table Style.
public
getStyle() : TableStyle
Return values
TableStylegetWorksheet()
Get Table's Worksheet.
public
getWorksheet() : Worksheet|null
Return values
Worksheet|nullisColumnInRange()
Validate that the specified column is in the Table range.
public
isColumnInRange(string $column) : int
Parameters
- $column : string
-
Column name (e.g. A)
Return values
int —The column offset within the table range
setAllowFilter()
Set show Autofiltering.
public
setAllowFilter(bool $allowFilter) : self
Disabling autofiltering has the same effect as hiding the filter button on all the columns in the table.
Parameters
- $allowFilter : bool
Return values
selfsetAutoFilter()
Set AutoFilter.
public
setAutoFilter(AutoFilter $autoFilter) : self
Parameters
- $autoFilter : AutoFilter
Return values
selfsetColumn()
Set Table.
public
setColumn(string|Column $columnObjectOrString) : self
Parameters
- $columnObjectOrString : string|Column
-
A simple string containing a Column ID like 'A' is permitted
Return values
selfsetName()
Set Table name.
public
setName(string $name) : self
Parameters
- $name : string
Tags
Return values
selfsetRange()
Set Table Cell Range.
public
setRange([AddressRange<string|int, CellAddress>|array{0: int, 1: int, 2: int, 3: int}|array{0: int, 1: int}|string $range = '' ]) : self
Parameters
- $range : AddressRange<string|int, CellAddress>|array{0: int, 1: int, 2: int, 3: int}|array{0: int, 1: int}|string = ''
-
A simple string containing a Cell range like 'A1:E10' is permitted or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), or an AddressRange object.
Return values
selfsetRangeToMaxRow()
Set Table Cell Range to max row.
public
setRangeToMaxRow() : self
Return values
selfsetShowHeaderRow()
Set show Header Row.
public
setShowHeaderRow(bool $showHeaderRow) : self
Parameters
- $showHeaderRow : bool
Return values
selfsetShowTotalsRow()
Set show Totals Row.
public
setShowTotalsRow(bool $showTotalsRow) : self
Parameters
- $showTotalsRow : bool
Return values
selfsetStyle()
Set table Style.
public
setStyle(TableStyle $style) : self
Parameters
- $style : TableStyle
Return values
selfsetWorksheet()
Set Table's Worksheet.
public
setWorksheet([Worksheet|null $worksheet = null ]) : self
Parameters
- $worksheet : Worksheet|null = null
Return values
selfshiftColumn()
Shift an Table Column Rule to a different column.
public
shiftColumn(string $fromColumn, string $toColumn) : self
Note: This method bypasses validation of the destination column to ensure it is within this Table range. Nor does it verify whether any column rule already exists at $toColumn, but will simply override any existing value. Use with caution.
Parameters
- $fromColumn : string
-
Column name (e.g. A)
- $toColumn : string
-
Column name (e.g. B)
Return values
selfcheckForDuplicateTableNames()
private
checkForDuplicateTableNames(string $name, Worksheet|null $worksheet) : void
Parameters
- $name : string
- $worksheet : Worksheet|null
Tags
updateStructuredReferences()
private
updateStructuredReferences(string $name) : void
Parameters
- $name : string
updateStructuredReferencesInCells()
private
updateStructuredReferencesInCells(Worksheet $worksheet, string $newName) : void
Parameters
- $worksheet : Worksheet
- $newName : string
updateStructuredReferencesInNamedFormulae()
private
updateStructuredReferencesInNamedFormulae(Spreadsheet $spreadsheet, string $newName) : void
Parameters
- $spreadsheet : Spreadsheet
- $newName : string