PHP将HTML的内容保存成word文档
<?php class word
{
function start()
{
ob_start();
echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<xml><w:WordDocument><w:View>Print</w:View></xml>
</head><body>';
}
function save($path)
{ echo "</body></html>";
$data = ob_get_contents();
ob_end_clean(); $this->wirtefile ($path,$data);
} function wirtefile ($fn,$data)
{
$fp=fopen($fn,"wb");
fwrite($fp,$data);
fclose($fp);
}
} /*生成doc文件*/
$html = '<style>
.onle_bm{ width:50%; line-height:50px; font-size:24px; text-align:center; color:#000;margin: 0px auto;}
.onle_bts{ width:50%; line-height:30px; font-size:16px; color:#666; margin:0px auto;}
.onle_bd{ width:50%; margin:0px auto; padding-top:20px;}
.onle_bd table{ border-right: 1px solid #000; border-bottom: 1px solid #000;height: 40px;}
.onle_bd td{font-size: 14px; color: #000; border-left: 1px solid #000; border-top: 1px solid #000;height: 40px;} </style><div class="onle_bm">国家登记表</div>
<div class="onle_bts">报名序号:<span>20170001</span></div>
<div class="onle_bd">
<form action="" method="get">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%" align="center"><p >报考岗位</p></td>
<td width="34%"><label for="textfield"><p>'.$_POST['bkgw'].'</p></label>
</td>
<td width="11%" align="center"><p >专业类别</p></td>
<td colspan="2">'.$_POST['sxzy'].'</td>
<td width="18%" rowspan="4"><img src="https://img6.bdstatic.com/img/image/smallpic/t2.jpg" width="100px" height="100px" /></td>
</tr>
<tr>
<td align="center"><p >姓名 </p></td>
<td><p>'.$_POST['username'].'</p></td>
<td align="center"><p >出生年月</p></td>
<td colspan="2" align="center"><p >'.$_POST['csmy'].'</p></td>
</tr>
<tr>
<td align="center"><p >户口所在地</p></td>
<td><p >'.$_POST['hjaddress'].'</p></td>
<td align="center"><p >性别</p></td>
<td colspan="2" align="center"><p >'.$_POST['sex'].'</p></td>
</tr>
<tr>
<td align="center"><p >政治面貌</p></td>
<td align="center"><p >'.$_POST['zzmm'].'</p></td>
<td align="center"><p >婚姻状况</p></td>
<td colspan="2" align="center"><p >'.$_POST['hyzk'].'</p></td>
</tr>
<tr>
<td align="center"><p >最高学历 </p></td>
<td align="center"><p >'.$_POST['zgxl'].'</p></td>
<td align="center"><p >毕业证号</p></td>
<td width="11%" align="center"><p>'.$_POST['byzh'].'</p></td>
<td width="12%" align="center"><p >学位</p></td>
<td align="center"><p >'.$_POST['degree'].'</p></td>
</tr>
<tr>
<td align="center"><p >毕业院校 </p></td>
<td colspan="3"><p>'.$_POST['byyx'].'</p></td>
<td align="center"><p >所学专业</p></td>
<td align="center"><p >'.$_POST['sxzy'].'</p></td>
</tr>
<tr>
<td align="center"><p >现工作单位</p></td>
<td colspan="3"><p>'.$_POST['xgzdw'].'</p></td>
<td align="center"><p >曾担任职务 </p></td>
<td align="center"><p >'.$_POST['cdrzw'].'</p></td>
</tr>
<tr>
<td align="center"><p >通讯地址</p></td>
<td colspan="3"><p>'.$_POST['txaddress'].'</p></td>
<td align="center"><p >邮政编码</p></td>
<td align="center"><p >'.$_POST['yzbm'].'</p></td>
</tr>
<tr>
<td align="center"><p >现居住地</p></td>
<td colspan="3">'.$_POST['xjzaddress'].'</td>
<td align="center"><p >移动电话</p></td>
<td align="center"><p>'.$_POST['ydphone'].'</p></td>
</tr>
<tr>
<td align="center"><p >身份证号</p></td>
<td><p>'.$_POST['idcard'].'</p></td>
<td align="center"><p >电子邮箱</p></td>
<td colspan="3"><p>'.$_POST['email'].'</p></td>
</tr>
<tr>
<td align="center"><p >掌握何种外语及程度</p></td>
<td align="center"><p >'.$_POST['zwwycd'].'</p></td>
<td align="center"><p >计算机掌握程度</p></td>
<td align="center"><p >'.$_POST['jsjzwcd'].'</p></td>
<td align="center"><p >有无刑事记录</p></td>
<td align="center"><p >'.$_POST['xsfzjl'].'</p></td>
</tr>
<tr>
<td align="center"><p >毕业年份</p></td>
<td align="center"><p >'.$_POST['bynf'].'</p></td>
<td colspan="3" align="center"><p >直系亲属是否从事商标代理</p></td>
<td align="center"><p >'.$_POST['zxqscssbdl'].'</p></td>
</tr>
<tr>
<td align="center"><p >学习经历 </p></td>
<td colspan="5"><label for="textarea"></label><p>
'.$_POST['xxjsxjl'].'</p></td>
</tr>
<tr>
<td align="center"><p >工作经历 </p></td>
<td colspan="5"><p>'.$_POST['gzjl'].'</p></td>
</tr>
<tr>
<td align="center"><p >奖惩情况</p></td>
<td colspan="5"><p>'.$_POST['jcqk'].'</p></td>
</tr>
<tr>
<td rowspan="2" align="center"><p align="center" >家庭成员和 <br />
主要社会 <br />
关系 </p></td>
<td align="center"><p >姓名 </p></td>
<td align="center"><p >关系 </p></td>
<td colspan="2" align="center"><p >所在单位职务 </p></td>
<td align="center"><p >政治面貌 </p></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<td align="center"><p >备注</p></td>
<td colspan="5">'.$_POST['bz'].'</td>
</tr>
</table> </form>
</div>
<div class="onle_bts">注:最高学历为国家承认的学历</div>
'; $html = file_get_contents("http://www.xxxx.com/test.html");
// echo $html;exit; $word = new word();
$word->start();
$wordname = 'word/test.doc';//生成文件路径
echo $html;
$word->save($wordname);
ob_flush();//每次执行前刷新缓存
flush();
/*生成doc文件 end*/
PHP将HTML的内容保存成word文档的更多相关文章
- “Word自动更改后的内容保存到通用文档模板上。是否加载该模板?“的解决办法
在win7系统下,Word2010出现了不能正常关闭.打开一个已有word文档,点击右上角关闭按钮后,先提示"word已停止工作,windows正在检查该问题的解决方案",随后提示 ...
- javadoc导出成word文档
刚刚上次弄完了一个坑爹的任务,这次我领导又给我一个让人脑瓜子疼的任务了. 基本上客户他在验收我们系统的时候,都会要求我们编写相关的文档,这次也不例外. 只是这次的客户要求我们给出接口文档.不仅是要整个 ...
- php将html转成word文档下载
<meta charset="utf-8" /> <?php class word{ function start(){ ob_start(); echo '&l ...
- ABBYY将JPEG文件转换成Word文档的方法
日常工作中处理JPEG格式的图像文件时,有时需要转换成Word文档进行编辑,市场上应用而生了很多转换工具,相信不少人听说过OCR(光学字符识别)软件,可以用来转换图像文件,而在OCR软件中, ABBY ...
- 如何使用ABBYY FineReader 12将JPEG文件转换成Word文档
日常工作中处理JPEG格式的图像文件时,有时需要转换成Word文档进行编辑,市场上应用而生了很多转换工具,相信不少人听说过OCR(光学字符识别)软件,可以用来转换图像文件,而在OCR软件中, ABBY ...
- 网页导出成word文档的默认视图方式问题
网页导出成word文档的默认视图方式问题 一般保存后的word文档默认是“Web版式视图”打开,这样会给客户的感觉不是真正的word文档,必须实现打开就是“页面视图” 1. 修改<html> ...
- HTML转换成word文档
1工具类保存word文件 public class WordAction { public static void SaveAsWord(string fileName, string pFileNa ...
- C# : 操作Word文件的API - (将C# source中的xml注释转换成word文档)
这篇博客将要讨论的是关于: 如何从C#的source以及注释, 生成一份Word格式的关于各个类,函数以及成员变量的说明文档. 他的大背景如下...... 最近的一个项目使用C#, 分N个模块, 在项 ...
- 将Latex tex文档转换成 word文档(上)
有时候逼不得已,必须得将自己精心排版好的latex 文档 转换成word 给别人编辑 以下提供一个方法 下载 Tex2Word 工具,地址我的网盘 安装 解压后安装,使用默认安装路径 安装过程中.点击 ...
随机推荐
- 如何判断NSDictionary是否包含某个键
方法一: if([[dictionary allKeys] containsObject:key){ // contains key} 方法二: if([dictionary objectFo ...
- IOS UI 滚动视图 UIScrollView
UIScrollView 常用属性 scrollView.maximumZoomScale= 2.0; // 缩放最大比例 scrollView.minimumZoomScale = 0.2;// ...
- java.lang.NoClassDefFoundError: javax/mail/Authenticator
摘录自:http://stackoverflow.com/questions/1630002/java-lang-noclassdeffounderror-javax-mail-authenticat ...
- shell实例练习+详解
想着将Shell与Python和Java等脚本比较比较,当一有这个念头我就放弃了.这太侮辱Shell了.(哭笑脸!) 作为一个程序员,Linux那是最基本要求.而shell脚本有时候也会显示它在Lin ...
- WinForm中,设置不显示窗口的标题栏
1:ControlBox设置False,然后标题为""的时候标题就不显示了2:把窗体设置为无边的窗体 FormBoderStyle 设为 None (在Mdi中,关闭按钮会还在) ...
- python_如何实现可迭代对象和迭代器对象?
什么是可迭代对象? 列表.字符串 for循环的本质? for循环要确保in后面的对象为可迭代对象,如何确保? iter() 方法得到一个迭代器对象 不停.__next__() 方法对迭代器对象进行迭代 ...
- 搭建Hadoop集群(centos6.7+hadoop-2.7.3)
hadoop集群有三种运行模式:单机模式.伪分布模式.完全分布模式.我们这里搭建第三种完全分布模式,即使用分布式系统,在多个节点上运行. 1 环境准备 1.1 配置DNS 进入配置文件,添加主节点和从 ...
- 1.JavaScript 教程:基础语法
简介: JavaScript web 开发人员必须学习的 3 门语言中的一门: HTML 定义了网页的内容 CSS 描述了网页的布局 JavaScript 网页的行为 用法: (1)HTML 中的脚本 ...
- asp.net core 部署到服务器之后外网访问不了
部署发现问题 今天在部署.net core的时候,发现访问http://localhost:xxxx可以,但是用外网访问并不行! 开始尝试解决问题 一开始以为是nginx的问题.各种折腾,各种改配置文 ...
- awk处理重复行错误分析
[root@localhost ~]#cat 0712 YRSD2-1-11 YRSD2-2-18 YRSD1-1-8 YRSD1-1-18 YRSD1-1-20 YRSD1-1-25 YRSD1-2 ...