Example #1
0
 /** {@inheritdoc} */
 public function create($path, array $firstRow, $sheetName = '')
 {
     $workbook = new Workbook();
     $sheet = new Sheet($workbook);
     $table = new Table();
     $table->setRow($firstRow);
     $sheet->addTable($table, new Coordinate(1, 1));
     $workbook->addSheet($sheet);
     $writerFactory = new WriterFactory();
     $writer = $writerFactory->createWriter(new Excel5($path));
     $phpExcel = $writer->convert($workbook);
     $writer->write($phpExcel);
 }
Example #2
0
 /**
  * Convert Table to PHPExcel_Worksheet data
  *
  * @param  PHPExcel_Worksheet $phpExcelWorksheet The current worksheet of the workbook
  * @param  Table              $table             The Table to convert
  *
  * @return PHPExcel_Worksheet
  */
 public function writeTable(PHPExcel_Worksheet $phpExcelWorksheet, Table $table)
 {
     $coordinate = $table->getCoordinate();
     // Labels handling
     if (null !== ($label = $table->getLabel())) {
         $this->labelWorker->writeLabel($label, $phpExcelWorksheet, $coordinate);
     }
     // Table handling
     foreach ($table->getTable() as $row) {
         foreach ($row as $index => $cell) {
             $this->cellWorker->writeCell($cell, $phpExcelWorksheet, $coordinate);
             $coordinate->nextXAxis();
         }
         $coordinate->resetXAxis()->nextYAxis();
     }
 }