Columns

Table::columns(array $columns) configures the per-column metadata. $columns is an array; each element is an associative array whose keys describe one column. Columns left out fall back to libxlsxwriter's defaults (Column1, Column2, ...).

Function prototype

\Vtiful\Kernel\Table::columns(array $columns): self

array $columns

Each entry supports the following keys:

  • header (string) — column title, replaces the default ColumnN.

  • formula (string) — column formula applied to every data row, e.g. '=SUM(Table1[@[Q1]:[Q4]])'.

  • total_string (string) — string shown in the total row for this column, e.g. 'Total'.

  • total_function (int) — total-row aggregator, one of Table::FUNCTION_*.

  • total_value (float) — explicit numeric value for the total row (normally derived from total_function).

  • format (Format|resource) — cell format for the data cells of this column. Accepts a Format instance or its resource handle.

  • header_format (Format|resource) — format for the header cell.

Table::FUNCTION_* constants: FUNCTION_NONE, FUNCTION_AVERAGE, FUNCTION_COUNT_NUMS, FUNCTION_COUNT, FUNCTION_MAX, FUNCTION_MIN, FUNCTION_STD_DEV, FUNCTION_SUM, FUNCTION_VAR.

Example

A sales table with four quarterly columns and a total row.

Last updated