PHP code example of eznio / tabler
1. Go to this page and download the library: Download eznio/tabler library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eznio / tabler example snippets
$tabler = (new \eznio\tabler\Tabler())
->setHeaders(['a' => 'Column A', 'b' => 'Column B', 'c' => 'Column C'])
->setData([
['a' => '123', 'b' => '456', 'c' => '7'],
['a' => '123', 'b' => '456', 'c' => '7'],
['a' => '123', 'b' => '456', 'c' => '7']
])
->setRenderer(new \eznio\tabler\renderers\MysqlStyleRenderer());
$layout = $tabler->getTableLayout();
$layout->getHeaderLine()->getHeaderCell('column2')
->setForegroundColor(\eznio\tabler\references\ForegroundColors::RED);
/** @var Tabler $tabler */
$tableLayout = $tabler->getTableLayout();
/** @var HeaderLine $headerLine */
$headerLine = $tableLayout->getheaderLine();
/** @var DataGrid $dataGrid */
$dataGrid = $tableLayout->getDataGrid();
/** @var HeaderCell $headerCellA */
$headerCellA = $headerLine->getHeaderCell('a');
/** @var DataRow $firstDataRow */
$firstDataRow = $dataGrid->getRow(0);
/** @var DataCell $dataCellA */
$dataCellA = $firstDataRow->getCell('a');
$tabler = new \eznio\tabler\Tabler();
$cell->setStyle(ForegroundColors::RED);
$cell->setStyle([
ForegroundColors::RED,
BacgroundColors::WHITE,
TextStyles::BOLD
]);
$tabler = (new \eznio\tabler\Tabler())
->setHeaders(['a' => 'Column A', 'b' => 'Column B', 'c' => 'Column C'])
->setData([
['a' => '123', 'b' => '456', 'c' => '7'],
['a' => '234', 'b' => '567', 'c' => '8'],
['a' => '345', 'b' => '6789', 'c' => '']
]);
$tabler->setRenderer(new MysqlStyleRenderer());
$tabler->setRenderer(new McStyleRenderer());
$tabler->setRenderer(new ClearStyleRenderer());
$tabler->setRenderer(new SingleLineRenderer());
$tabler = (new \eznio\tabler\Tabler())
->setHeaders(['a' => 'Column A', 'b' => 'Column B', 'c' => 'Column C'])
->setData([
['a' => '123', 'b' => '456', 'c' => '7'],
['a' => '234', 'b' => '567', 'c' => '8'],
['a' => '345', 'b' => '6789', 'c' => '']
])
->setRenderer(new \eznio\tabler\renderers\SingleLineRenderer())
->setGuessHeaderNames(false);
$layout = $tabler->getTableLayout();
$layout->getHeaderLine()->getHeaderCell('a')
->setTextAlignment(\eznio\tabler\references\TextAlignments::TEXT_ALIGN_LEFT)
->setForegroundColor(\eznio\styler\references\ForegroundColors::RED);
$layout->getHeaderLine()->getHeaderCell('b')
->setTextAlignment(\eznio\tabler\references\TextAlignments::TEXT_ALIGN_CENTER)
->setForegroundColor(\eznio\styler\references\ForegroundColors::YELLOW);
$layout->getHeaderLine()->getHeaderCell('c')
->setTextAlignment(\eznio\tabler\references\TextAlignments::TEXT_ALIGN_RIGHT)
->setForegroundColor(\eznio\styler\references\ForegroundColors::GREEN);
$layout->getDataGrid()->getRow(1)->getCell('c')
->setTextAlignment(\eznio\tabler\references\TextAlignments::TEXT_ALIGN_CENTER);
echo $tabler->render($layout);
setData(array $data)
setHeaders(array $headers)
setHeadingLineStyles(array $styles)
setHeadingCellStyles($columnId, array $styles)
setColumnStyles($columnId, array $styles)
setRowStyles($rowId, array $styles)
setOddRowsStyles(array $styles)
setEvenRowsStyles(array $styles)