用PHP生成单词文档

前端之家收集整理的这篇文章主要介绍了用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.f2er.com/php/140085.html

猜你在找的PHP相关文章