/** * Add cell */ public function testAddCell() { $oRow = new Row('section', 1); $element = $oRow->addCell(); $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Cell', $element); $this->assertCount(1, $oRow->getCells()); }
/** * Add a row * * @param int $height * @param mixed $style * @return \PhpOffice\PhpWord\Element\Row */ public function addRow($height = null, $style = null) { $row = new Row($height, $style); $row->setParentContainer($this); $this->rows[] = $row; return $row; }
/** * Add a row * * @param int $height * @param mixed $style * @return \PhpOffice\PhpWord\Element\Row */ public function addRow($height = null, $style = null) { $row = new Row($height, $style); $row->setDocPart($this->getDocPart(), $this->getDocPartId()); $row->setPhpWord($this->phpWord); $row->setNestedLevel($this->getNestedLevel()); $this->rows[] = $row; return $row; }
/** * Write row * * @return string */ private function writeRow(RowElement $row) { $content = ''; // Write cells foreach ($row->getCells() as $cell) { $content .= $this->writeCell($cell); } return $content; }
/** * Write row. * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Element\Row $row * @return void */ private function writeRow(XMLWriter $xmlWriter, RowElement $row) { $xmlWriter->startElement('w:tr'); // Write style $rowStyle = $row->getStyle(); if ($rowStyle instanceof RowStyle) { $styleWriter = new RowStyleWriter($xmlWriter, $rowStyle); $styleWriter->setHeight($row->getHeight()); $styleWriter->write(); } // Write cells foreach ($row->getCells() as $cell) { $this->writeCell($xmlWriter, $cell); } $xmlWriter->endElement(); // w:tr }