作者:乔山办公网日期:
返回目录:word文档
第一步、打开网页后单百击浏览器菜单栏的“文件”-->另存为,然后选择“网页,全部htm,html”格式;(如下图):
第二步、我们打开Word,然后选择Word菜单栏的“文件”-->打开,找到刚才保存文件的地方,度选择打开(如:我这问里打开“《Excel2003如何合并单元格》”这个页面):
步骤三、打开以后我们删除一些不需要的地方,比如:顶部和底部的,那些对于我们来说都没什么用,答我们要主要就是要内容。内然后打开菜单栏的“表格”-->转换-->表格转换为文本,将一些文档中的表格一一去掉。
最后步、修改了一下效果跟先容前那个比起来是不是要好得多呀?我们将修改好的文档“另存为”或者“保存”普通的(.doc)格式就可以了。
打开 HTML 文件,点击菜单栏 文件→使用 Microsoft Office Word 编辑,之后抄系统会自动打开 Word 并显示HTML文件的内袭容,这是保存即可。
如果找不到“使用 Microsoft Office Word 编辑zd”的话,点击菜单栏 工具→Internet 选项→程序→ HTML 编辑器 → Microsoft Office Word → 确定。
java将7a686964616fe58685e5aeb9335html导出word不用忘记<html></html>这对标签
//换页
<span style='font-size:16px;line-height:150%;font-family:"Times New Roman";
mso-fareast-font-family:宋体;mso-font-kerning:1px;mso-ansi-language:EN-US;
mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all style='mso-special-character:page-break;page-break-before:always'>
</span>
//换行
<p style='line-height:150%'><span style='font-size:16px;line-height:150%'><o:p> </o:p></span></p>
查看的话 打开word 视图——页面 就能看出看出效果
[java] view plain copy print?
ArrayList records = form.getRecords();//获取数据库数据
if(null!=records&&0!=records.size()){
//html拼接出word内容
String content="<html>";
for (int i = 0; i < records.size(); i++) {
Record record =(Record) records.get(i);
//从数据库中获得数据,将oracle中的clob数据类型转换成string类型
Method method = record.get("CONTENT").getClass().getMethod("getVendorObj",new Class[]{});
CLOB clob = (CLOB)method.invoke(record.get("CONTENT"));
String cx = clob.getSubString((long) 1, (int) clob.length());
String title= (String) record.get("TITLE");
//html拼接出word内容
content+="<div style=\"text-align: center\"><span style=\"font-size: 24px\"><span style=\"font-family: 黑体\">"+title+"<br /> <br /> </span></span></div>";
content+="<div style=\"text-align: left\"><span >"+cx+"<br /> <br /> </span></span></div>";
//插入分页符
content+="<span lang=EN-US style='font-size:16px;line-height:150%;mso-fareast-font-family:宋体;mso-font-kerning:1px;mso-ansi-language:EN-US;mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all style='page-break-before:always'></span>";
content+="<p class=MsoNormal style='line-height:150%'><span lang=EN-US style='font-size:16px;line-height:150%'><o:p> </o:p></span></p>";
}
content += "</html>";
byte b[] = content.getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(b);
POIFSFileSystem poifs = new POIFSFileSystem();
DirectoryEntry directory = poifs.getRoot();
DocumentEntry documentEntry = directory.createDocument("WordDocument", bais);
//输出文件
String name="导出知识";
response.reset();
response.setHeader("Content-Disposition",
"attachment;filename=" +
new String( (name + ".doc").getBytes(),
"iso-8859-1"));
response.setContentType("application/msword");
OutputStream ostream = response.getOutputStream();
//输出文件的话,new一个文件流
//FileOutputStream ostream = new FileOutputStream(path+ fileName);
poifs.writeFilesystem(ostream);
ostream.flush();
ostream.close();
bais.close();
两种方式:
1、纯来Java,用POI来做
2、用JNA调用word接口,根据office api来做
第一种呢对于java开发来说相对源简单,但是需知要学POI,而且估计有些格式控制不好。第二种要学习JNA,而且需要边做变差道word的office api。