Example:
$workbook = new cells\Workbook(); $firstColumnStyle = $workbook->createStyle(); $firstColumnStyle->setPattern(cells\BackgroundType::SOLID); $firstColumnStyle->setBackgroundColor(cells\Color::getRed()); $lastColumnStyle = $workbook->createStyle(); $lastColumnStyle->getFont()->setBold(true); $lastColumnStyle->setPattern(cells\BackgroundType::SOLID); $lastColumnStyle->setBackgroundColor(cells\Color::getRed()); $tableStyleName = "Custom1"; $tableStyles = $workbook->getWorksheets()->getTableStyles(); $index1 = $tableStyles->addTableStyle($tableStyleName); $tableStyle = $tableStyles->get($index1); $elements = $tableStyle->getTableStyleElements(); $index1 = $elements->add(cells\TableStyleElementType::FIRST_COLUMN); $element = $elements->get($index1); $element->setElementStyle($firstColumnStyle); $index1 = $elements->add(cells\TableStyleElementType::LAST_COLUMN); $element = $elements->get($index1); $element->setElementStyle($lastColumnStyle); $cells = $workbook->getWorksheets()->get(0)->getCells(); for ($i = 0; $$i < 5; $i++) { $cells->get(0, $i)->putValue(cells\CellsHelper::columnIndexToName($i)); } for ($row = 1; $row < 10; $row++) { for ($column = 0; $column < 5; $column++) { $cells->get($row, $column)->putValue($row * $column); } } $tables = $workbook->getWorksheets()->get(0)->getListObjects(); $index = $tables->add(0, 0, 9, 4, true); $table = $tables->get(0); $table->setShowTableStyleFirstColumn(true); $table->setShowTableStyleLastColumn(true); $table->setTableStyleName($tableStyleName);
Property Getters/Setters Summary | ||
---|---|---|
function | getName() | |
Gets the name of table style.
|
||
function | getTableStyleElements() | |
Gets all elements of the table style.
|
function getName()
function getTableStyleElements()