您的位置:首页 > 编程语言 > PHP开发

php将网页导出word文档

2011-10-24 16:31 465 查看
公司的招聘网站为了做导出简历的功能,上网查了好多资料,终于找到了一个简便实用的方法。

原理:指定文档类型,文件名。输出HTML代码,So easy!

php导出word文档,实例代码如下:

<?php

header("Content-Type: application/msword");

header("Content-Disposition: attachment; filename=doc.doc");
//指定文件名称

header("Pragma: no-cache");

header("Expires: 0");

$html = '<table border="1" cellspacing="2"cellpadding="2" width="90%"align="center">';

$html .= '<trbgcolor="#cccccc"><tdalign="center">博客</td></tr>';

$html .= '<trbgcolor="#f6f7fa"><td><spanstyle="color:#FF0000;"><strong>PHP将网页代码导出word文档</strong></span></td></tr>';

$html .= '<tr><tdalign="center"><imgsrc="/upload/header.gif"></td></tr>';//自定义图片文件

$html .= '</table>';

echo $html;

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: