加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

用PHP生成单词文档

发布时间:2020-05-25 09:42:44 所属栏目:PHP 来源:互联网
导读:参见英文答案 Create Word Document using PHP in Linux10个 你有没有办法用PHP和没有COM组件生成doc和docx文件?我尝试过PHPWord,它创建了docx文件,但这些文件无法在OpenOffice中打开,因为它们会导致崩溃.我也尝试过PHPDocx,但是根本没有生成任何文件.

参见英文答案 > 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>";
?>

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读