コード例 #1
0
ファイル: Table.php プロジェクト: Senasum/PHPWord
 /**
  * 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
 }
コード例 #2
0
 private function parseTable(Table $table, iCallback $callback)
 {
     foreach ($table->getRows() as $row) {
         foreach ($row->getCells() as $cell) {
             $this->parseContainer($cell, $callback);
         }
     }
 }
コード例 #3
0
ファイル: TableTest.php プロジェクト: kaantunc/MYK-BOR
 /**
  * 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);
 }