예제 #1
0
 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++;
 }
예제 #2
0
 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);
 }
예제 #3
0
 public function renderTable(\TableContent $content)
 {
     $params = $content->getDataParams();
     $style = array('header:border' => array(200, 200, 200), 'header:background' => array(200, 200, 200), 'header:text' => array(255, 255, 255), 'body:background' => array(255, 255, 255), 'body:stripe' => array(250, 250, 250), 'body:border' => array(200, 200, 200), 'body:text' => array(0, 0, 0), 'decoration' => true);
     if ($content->getAsTotalsBox()) {
         $this->pdf->totalsBox($content->getData(), $params);
     } else {
         if ($content->getAutoTotals()) {
             $this->pdf->table($content->getHeaders(), $content->getData(), $style, $params);
             $totals = $content->getTotals();
             $totals[0] = "Totals";
             $this->pdf->totalsBox($totals, $params);
         } else {
             $this->pdf->table($content->getHeaders(), $content->getData(), $style, $params);
         }
     }
 }