Home > php教程 > php手册 > 如何用PHP生成word文档

如何用PHP生成word文档

WBOY
Release: 2016-06-07 11:36:26
Original
1303 people have browsed it

PHP操作Word文档的方法有很多,这里为大家提供一种高效方法,要比服务器安装com组件效率高的多,因为 word的com组件还要打开客户端。
如何用PHP生成word文档
首先保证你的服务器安装Microsoft Office
本文以下载素材火的特效页面,作为word输出内容。当然你也可以自定义字符串内容,比如表格、列表、标题等。
若是有图片的话,咱们必须转换成mht格式。
PHP生成word,并即时下载代码:
$url = file_get_contents("http://www.sucaihuo.com/js");
$fileContent = getWordDocument($url);
$fileName = iconv("utf-8", "GBK", '素材火' . '_' . $id . '_' . rand(100, 999));
header("Content-Type: application/doc");
header("Content-Disposition: attachment; filename=" . $fileName . ".doc");
echo $fileContent;
PHP在线生成word文档演示地址:http://www.sucaihuo.com/php/529.html

附件 PHP在线生成word文档.zip ( 4.14 KB 下载:90 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template