add exmpales
[pear-examples] / Document_Word_Writer / Examples / BasicTable.php~
1 <?php
2 ini_set('include_path', __DIR__  . '../../..');
3 require_once 'Document/Word/Writer.php';
4
5 // New Word Document
6 $PHPWord = new Document_Word_Writer();
7
8 // New portrait section
9 $section = $PHPWord->createSection();
10
11 // Add table
12 $table = $section->addTable();
13
14 for($r = 1; $r <= 10; $r++) { // Loop through rows
15         // Add row
16         $table->addRow();
17         
18         for($c = 1; $c <= 5; $c++) { // Loop through cells
19                 // Add Cell
20                 $table->addCell(1750)->addText("Row $r, Cell $c");
21         }
22 }
23
24 // Save File
25 require_once 'Document/Word/Writer/IOFactory.php';
26 $objWriter = Document_Word_Writer_IOFactory::createWriter($PHPWord, 'Word2007');
27 $objWriter->save('BasicTable.docx');
28 ?>