Ejemplo n.º 1
0
 /**
  * Write column.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\Table $element
  * @return void
  */
 private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
 {
     $rows = $element->getRows();
     $rowCount = count($rows);
     $cellWidths = array();
     for ($i = 0; $i < $rowCount; $i++) {
         $row = $rows[$i];
         $cells = $row->getCells();
         if (count($cells) <= count($cellWidths)) {
             continue;
         }
         $cellWidths = array();
         foreach ($cells as $cell) {
             $cellWidths[] = $cell->getWidth();
         }
     }
     $xmlWriter->startElement('w:tblGrid');
     foreach ($cellWidths as $width) {
         $xmlWriter->startElement('w:gridCol');
         if ($width !== null) {
             $xmlWriter->writeAttribute('w:w', $width);
             $xmlWriter->writeAttribute('w:type', 'dxa');
         }
         $xmlWriter->endElement();
     }
     $xmlWriter->endElement();
     // w:tblGrid
 }
Ejemplo n.º 2
0
 private function parseTable(Table $table, iCallback $callback)
 {
     foreach ($table->getRows() as $row) {
         foreach ($row->getCells() as $cell) {
             $this->parseContainer($cell, $callback);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Add cell
  */
 public function testCountColumns()
 {
     $oTable = new Table('section', 1);
     $oTable->addRow();
     $element = $oTable->addCell();
     $this->assertEquals($oTable->countColumns(), 1);
     $element = $oTable->addCell();
     $element = $oTable->addCell();
     $this->assertEquals($oTable->countColumns(), 3);
 }