首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置和运行PHPWord

配置和运行PHPWord
EN

Stack Overflow用户
提问于 2012-07-10 21:49:21
回答 1查看 2.5K关注 0票数 0

我正在尝试根据PHPWord example的示例生成一个word模板。但没有生成word模板或无法成功显示页面。我已经过滤掉了示例代码,并且只添加了hello world的一部分!

代码语言:javascript
复制
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服务器中吗?还是临时文件夹?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2017-07-04 22:11:19

如果您希望您的网页强制下载生成的文档,只需使用以下命令:

代码语言:javascript
复制
$PHPWord->save('helloWorld.docx', 'Word2007', true);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11414790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档