addTable
addTable
BASIC / ADVANCED / PREMIUM
Adds tables into the Excel spreadsheet.
Description
public addTable($contents, $position, $tableStyles = array(), $options = array())
This method allows adding a table in the active sheet.
Parameters
contents
A multidimensional array with the contents and styles to be added. Check addCell to see all available options.
position
Cell position in the active sheet: A1, C3, AB7...
tableStyles
The possible keys and values of this array are:
Key | Type | Description |
---|---|---|
bandedColumn | bool | Banded column option. Default as false. |
bandedRow | bool | Banded row option. Default as true. |
firstColumn | bool | First column option. Default as false. |
headerRow | bool | Header row option. Default as false. |
lastColumn | bool | Last column option. Default as false. |
tableStyle | string | Table style name. MS Excel includes built-in table style names: TableStyleMedium2, TableStyleLight3... |
totalRow | bool | Total row option. Default as false. |
options
The possible keys and values of this array are:
Key | Type | Description |
---|---|---|
columnNames | array | Custom column names. If not set, 'Column ' is used to generate names. |
columnTotals | array |
|
description | string | Alternative text description. |
filters | array |
custom (array):
values (array) |
tableName | string | Custom table name. If not set a new table name is generated automatically. |
title | string | Alternative text title. |
Return values
Array with the position range added by the method.
Exceptions
Table name exists in the spreadsheet.
Code samples
Release notes
- phpxlsx 2.5:
- title and description options.
- apply content types to contents and totals.
- return the position range.
- phpxlsx 2.0:
- filters.
- phpxlsx 1.0:
- new method.