Jsp页面Word文档的生成

  1. 首先建一Word文档模板,并预先进行相关内容填充。


  2. 将Word文档另存为htm格式,如果存为筛选过的网页(html),则相关的页眉页脚等格式信息会丢失。


  3. 将html的内容拷贝到Jsp页面即可。并将原先填充的内容用动态内容替换即可。
      如果要以附件形式显示,则在Jsp页面中加入以下代码:

   

response.setContentType("application/msword"); 
String fileName = "JL-6-11-5市场巡查情况记录表.doc";
response.setHeader("Content-Disposition", "attachment; filename=\""
		 + new String(fileName.getBytes("GBK"), "ISO8859-1") + "\"");

 

 4. 如果存在页眉页脚信息,url如果为动态页面,需提供完整的url路径(含http前缀)。

 

   

@page
{mso-mirror-margins:yes;
mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;
mso-footnote-separator:url("<%=headJsp%>") fs;
mso-footnote-continuation-separator:url("<%=headJsp%>") fcs;
mso-endnote-separator:url("<%=headJsp%>") es;
mso-endnote-continuation-separator:url("<%=headJsp%>") ecs;}

 

5. 如需控制文档分页,则插入以下分页符代码:

 

 <span lang=EN-US style='font-size:10.5pt;font-family:宋体;mso-bidi-font-family:
	 "Times New Roman";color:red;mso-font-kerning:1.0pt;mso-ansi-language:EN-US;
	 mso-fareast-language:ZH-CN;mso-bidi-language:AR-SA'><br clear=all
	 style='mso-special-character:line-break;page-break-before:always'>
 </span>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值