用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>";
?>

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...