我正在尝试根据PHPWord example的示例生成一个word模板。但没有生成word模板或无法成功显示页面。我已经过滤掉了示例代码,并且只添加了hello world的一部分!
Code:
<?php
require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$section = $PHPWord->createSection();
$section->addText('Hello world!');
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');
?>如果我使用objwriter->保存helloworld.docx,请给我建议。它会自动出现在我的web服务器中吗?还是临时文件夹?
谢谢!
发布于 2017-07-04 22:11:19
如果您希望您的网页强制下载生成的文档,只需使用以下命令:
$PHPWord->save('helloWorld.docx', 'Word2007', true);https://stackoverflow.com/questions/11414790
复制相似问题