我已经按照这里关于在 Codeigniter 中安装 PHPWord 的所有说明进行操作
我只是不知道在哪里可以找到我的输出文件(filename.docx)以及如何知道它是否正常工作。没有错误信息。
这是我的代码:
$PHPWord = $this->word; $section = $PHPWord->createSection(array('orientation'=>'landscape')); $section->addText('Hello World!'); $section->addTextBreak(2); $section->addText('I am inline styled.', array('name'=>'Verdana', >'color'=>'006699')); $section->addTextBreak(2); $PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, >'size'=>16)); $PHPWord->addParagraphStyle('pStyle', array('align'=>'center', >'spaceAfter'=>100)); $section->addText('I am styled by two style definitions.', 'rStyle', >'pStyle'); $section->addText('I have only a paragraph style definition.', null, >'pStyle'); $filename='kem.docx'; //save our document as this file name header('Content-Type: application/vnd.openxmlformats->officedocument.wordprocessingml.document'); //mime type header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell >browser what's the file name header('Cache-Control: max-age=0'); //no cache $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output');
顺便说一句,我正在使用 ubuntu 12.04 LTS