2 ini_set('include_path', __DIR__ . '/../../..:.');
3 require_once __DIR__ . '/../Writer.php';
5 $PHPWord = new Document_Word_Writer();
7 // New portrait section
8 $section = $PHPWord->createSection();
11 $table = $section->addTable();
13 $cellStyle = array('bgColor'=>'C0C0C0');
15 $table = $section->addTable();
17 $table->addCell(2000, $cellStyle)->addText('Cell 1');
18 $table->addCell(2000, $cellStyle)->addText('Cell 2');
19 $table->addCell(2000, $cellStyle)->addText('Cell 3');
21 $table->addCell(2000)->addText('Cell 4');
22 $table->addCell(2000)->addText('Cell 5');
23 $table->addCell(2000)->addText('Cell 6');
26 require_once __DIR__ . '/../Writer/IOFactory.php';
27 $objWriter = Document_Word_Writer_IOFactory::createWriter($PHPWord, 'Word2007');
28 $objWriter->save('/tmp/BasicTable.docx');
30 // Download the file for testing
31 if($_SERVER['SERVER_NAME'] == 'localhost')
35 $file = '/tmp/BasicTable.docx';
36 if (file_exists($file)) {
37 echo 'Prepare for download!!';
38 header('Content-Description: File Transfer');
39 header('Content-Type: application/octet-stream');
40 header('Content-Disposition: attachment; filename='.basename($file));
41 header('Content-Transfer-Encoding: binary');
43 header('Cache-Control: must-revalidate');
44 header('Pragma: public');
45 header('Content-Length: ' . filesize($file));