BasicTable.php 523 B

1234567891011121314151617181920212223242526
  1. <?php
  2. require_once '../PHPWord.php';
  3. // New Word Document
  4. $PHPWord = new PHPWord();
  5. // New portrait section
  6. $section = $PHPWord->createSection();
  7. // Add table
  8. $table = $section->addTable();
  9. for($r = 1; $r <= 10; $r++) { // Loop through rows
  10. // Add row
  11. $table->addRow();
  12. for($c = 1; $c <= 5; $c++) { // Loop through cells
  13. // Add Cell
  14. $table->addCell(1750)->addText("Row $r, Cell $c");
  15. }
  16. }
  17. // Save File
  18. $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
  19. $objWriter->save('BasicTable.docx');
  20. ?>