/** * * {@inheritDoc} * * @see \SK\ITCBundle\Service\Table\Adapter\IAdapter::write() */ public function write(Table $table, OutputInterface $output) { $this->getSpreadsheet()->getProperties()->setTitle($table->getTitle())->setDescription($table->getDescription()); $this->writeHeaders($table->getHeaders()); $this->writeRows($table->getRows()); $writer = IOFactory::createWriter($this->getSpreadsheet(), 'CSV'); $writer->save('php://output'); }
/** * * {@inheritDoc} * * @see \SK\ITCBundle\Service\Table\Adapter\IAdapter::write() */ public function write(Table $table, OutputInterface $output) { $style = new TableStyle(); $style->setHorizontalBorderChar('<fg=magenta>-</>')->setVerticalBorderChar('<fg=magenta>|</>')->setCrossingChar('<fg=magenta>+</>'); $stable = new STable($output); $stable->setStyle('default'); $stable->setHeaders($table->getHeaders()); $columns = $table->getColumns(); $colspan = count($columns); $rows = $table->getRows(); foreach ($rows as $row) { $rowModificated = []; foreach ($columns as $iCol => $col) { if (is_int($iCol)) { $iCol = $col; } if (array_key_exists($iCol, $row)) { $rowModificated[$iCol] = wordwrap($row[$iCol], $table->getMaxColWidth(), "\n", true); } else { $rowModificated[$iCol] = ""; } } $stable->addRow($rowModificated); $stable->addRow(array(new TableSeparator(array('colspan' => $colspan)))); } $stable->addRow(array(new TableCell("", array('colspan' => $colspan)))); $stable->addRow(array(new TableCell(sprintf("Found %s results.", count($rows)), array('colspan' => $colspan)))); $stable->render(); }
/** */ protected function getTable() { $this->table->setColumns($this->getColumns()); $this->table->setRows($this->getRows()); $this->table->setTitle($this->getName()); $this->table->setDescription($this->getDescription()); return $this->table; }