Example #1
0
 /**
  * New instance with array
  */
 public function testConstructWithStyleArray()
 {
     $iVal = rand(1, 1000);
     $oCell = new Cell('section', $iVal, null, array('valign' => 'center'));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Cell', $oCell->getStyle());
     $this->assertEquals($oCell->getWidth(), null);
 }
Example #2
0
 /**
  * Write cell.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\Cell $cell
  * @return void
  */
 private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
 {
     $xmlWriter->startElement('w:tc');
     // Write style
     $cellStyle = $cell->getStyle();
     if ($cellStyle instanceof CellStyle) {
         $styleWriter = new CellStyleWriter($xmlWriter, $cellStyle);
         $styleWriter->setWidth($cell->getWidth());
         $styleWriter->write();
     }
     // Write content
     $containerWriter = new Container($xmlWriter, $cell);
     $containerWriter->write();
     $xmlWriter->endElement();
     // w:tc
 }
Example #3
0
 /**
  * New instance with array
  */
 public function testConstructWithStyleArray()
 {
     $oCell = new Cell(null, array('valign' => 'center'));
     $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Cell', $oCell->getStyle());
     $this->assertNull($oCell->getWidth());
 }