微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用PHP生成单词文档

参见英文答案 > Create Word Document using PHP in Linux10个
你有没有办法用PHP和没有COM组件生成doc和docx文件?我尝试过PHPWord,它创建了docx文件,但这些文件无法在OpenOffice中打开,因为它们会导致崩溃.我也尝试过phpdocx,但是根本没有生成任何文件.
看这里:

http://www.webcheatsheet.com/php/create_word_excel_csv_files_with_php.php

引用文章最常见的方法

使用HTTP头

In this method you need to format the HTML/PHP page using
Word-friendly CSS and add header information to your PHP script. Make
sure you don’t use external style sheets since everything should be in
the same file.

As a result user will be prompted to download a file. This file will
not be 100% “original” Word document,but it certainly will open in MS
Word application. You can use this method both for Unix and Windows
environments.

<?PHP
  header("Content-type: application/vnd.ms-word");
  header("Content-disposition: attachment;Filename=document_name.doc");    
  echo "<html>";
  echo "<Meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\">";
  echo "<body>";
  echo "<b>My first document</b>";
  echo "</body>";
  echo "</html>";
?>

原文地址:https://www.jb51.cc/php/140085.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐