Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @throws ParsingException
  */
 public function build(Sheet $sheet, $yamlContent, Scope $scope)
 {
     // Init TwigExecutor with all user functions.
     $this->twigExecutor = new TwigExecutor($scope->getFunctions());
     // Table.
     $table = new Table();
     $sheet->addTable($table);
     if (isset($yamlContent) && isset($yamlContent['label'])) {
         $table->setLabel($this->twigExecutor->parse($yamlContent['label'], $scope));
     }
     // Columns.
     if (!isset($yamlContent) || !array_key_exists('columns', $yamlContent)) {
         throw new ParsingException("'content' of type 'VerticalTable' must contains 'columns'");
     }
     foreach ($yamlContent['columns'] as $yamlColumn) {
         $this->parseColumn($table, $yamlColumn, $scope);
     }
     // Lines.
     if (!isset($yamlContent) || !array_key_exists('lines', $yamlContent)) {
         throw new ParsingException("'content' of type 'VerticalTable' must contains 'lines'");
     }
     foreach ($yamlContent['lines'] as $yamlLine) {
         $this->parseLine($table, $yamlLine, $scope);
     }
 }
Exemplo n.º 2
0
 private function processSheet(Sheet $sheet, PHPExcel_Worksheet $phpExcelSheet)
 {
     if ($sheet->getLabel()) {
         $phpExcelSheet->setTitle(mb_substr($sheet->getLabel(), 0, 31));
     }
     // Process tables
     $lineOffset = 1;
     $maxColumnCount = 0;
     foreach ($sheet->getTables() as $table) {
         $this->processTable($table, $phpExcelSheet, $lineOffset);
         $lineOffset += count($table->getLines());
         // Add an empty line after each table
         $lineOffset++;
         $maxColumnCount = max($maxColumnCount, count($table->getColumns()));
     }
     // Set auto size for col's width
     for ($columnIndex = 0; $columnIndex <= $maxColumnCount; $columnIndex++) {
         $phpExcelSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($columnIndex))->setAutoSize(true);
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function build(Sheet $sheet, $yamlContent, Scope $scope)
 {
     $table = new Table();
     $table->addLine(new Line());
     $sheet->addTable($table);
 }