
Untitled
By: a guest on
Dec 30th, 2011 | syntax:
None | size: 0.77 KB | hits: 91 | expires: Never
<?
require_once '../libs/PHPWord.php';
//$PHPWord = new PHPWord();
$include_headers = false;
// Create a new PHPWord Object
$PHPWord = new PHPWord();
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();
$Text_to_Add = htmlentities("Me & my Code");
$section->addText($Text_to_Add);
// At least write the document to webspace:
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=helloWorld.docx");
header("Content-Type: application/docx");
header("Content-Transfer-Encoding: binary");
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('helloWorld.docx');