public function renderTable(TableContent $content) { $style = array('header:border' => $this->convertColor(array(200, 200, 200)), 'header:background' => $this->convertColor(array(200, 200, 200)), 'header:text' => $this->convertColor(array(255, 255, 255)), 'body:background' => $this->convertColor(array(255, 255, 255)), 'body:stripe' => $this->convertColor(array(250, 250, 250)), 'body:border' => $this->convertColor(array(200, 200, 200)), 'body:text' => $this->convertColor(array(0, 0, 0))); if ($content->getAsTotalsBox()) { $totals = $content->getData(); for ($i = 0; $i < $this->numColumns; $i++) { $this->worksheet->setCellValueByColumnAndRow($i, $this->row, $totals[$i]); $this->worksheet->getStyleByColumnAndRow($i, $this->row)->getFont()->setBold(true); $this->worksheet->getStyleByColumnAndRow($i, $this->row)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK)->getColor()->setRGB($style['body:border']); } } else { $headers = $content->getHeaders(); $this->numColumns = count($headers); $col = 0; foreach ($headers as $header) { $this->worksheet->setCellValueByColumnAndRow($col, $this->row, str_replace("\\n", "\n", $header)); $this->worksheet->getStyleByColumnAndRow($col, $this->row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $this->worksheet->getStyleByColumnAndRow($col, $this->row)->getFill()->getStartColor()->setRGB($style['header:background']); $this->worksheet->getStyleByColumnAndRow($col, $this->row)->getFont()->setBold(true)->getColor()->setRGB($style['header:text']); $col++; } $fill = false; $types = $content->getDataTypes(); $widths = $content->getTableWidths(); foreach ($content->getData() as $rowData) { $this->row++; $col = 0; $this->renderRow($rowData, $types, $style, $fill); $fill = !$fill; } } $this->row++; }
public function renderTable(TableContent $content) { $templates = array('widths' => $content->getTableWidths(), 'as_totals_box' => $content->getAsTotalsBox(), 'num_columns' => $content->getNumColumns(), 'data' => $content->getData(), 'headers' => $content->getHeaders(), 'auto_totals' => $content->getAutoTotals(), 'types' => $content->getDataTypes()); if ($templates['auto_totals']) { $templates['totals'] = $content->getTotals(); } $this->markup .= TemplateEngine::render(__DIR__ . '/html_templates/table.tpl', $templates); }