`
sklst
  • 浏览: 38403 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

用jsp生成Word文档

    博客分类:
  • J2EE
阅读更多
这个跟网上提供的有所不同,所有的输出内容是用标签来实现。
<%@ page language="java" contentType = "application/vnd.ms-excel; charset=gbk"%>
<%@ page language="java" pageEncoding="GBK"%>

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<%
response.setContentType("application/msword");
String filename = new String(("调查报告").getBytes("GBK"),"ISO-8859-1");
response.setHeader("Content-Disposition", "inline; filename=\""+filename+".doc\"");
%> 
<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>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>调查管理系统</o:Author>
  <o:LastAuthor>调查管理系统</o:LastAuthor>
  <o:Revision>1</o:Revision>
  <o:TotalTime>0</o:TotalTime>
  <o:Created>2008-12-12T05:06:00Z</o:Created>
  <o:LastSaved>2008-12-12T05:06:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Company>WwW.YlmF.CoM</o:Company>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:Version>11.9999</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:PunctuationKerning/>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-alt:SimSun;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;
	mso-font-charset:134;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:3 135135232 16 0 262145 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	font-size:10.5pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:宋体;
	mso-font-kerning:1.0pt;}
h1
	{mso-style-next:正文;
	margin-top:17.0pt;
	margin-right:0cm;
	margin-bottom:16.5pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:240%;
	mso-pagination:lines-together;
	page-break-after:avoid;
	mso-outline-level:1;
	font-size:22.0pt;
	font-family:"Times New Roman";
	mso-font-kerning:22.0pt;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;
	layout-grid:15.6pt;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:普通表格;
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";
	mso-ansi-language:#0400;
	mso-fareast-language:#0400;
	mso-bidi-language:#0400;}
</style>
<![endif]-->
</head>

<body style='tab-interval:21.0pt;text-justify-trim:punctuation'>

<div style='layout-grid:15.6pt'>

<p><span><o:p><br>&nbsp;</o:p></span></p>

</div>

<logic:notEmpty name="list">
<logic:iterate id="listPrint" name="list">
<p align="center"><strong>XX保险股份有限公司调查报告书</strong></p>
<table width="630" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="68" height="28" valign="top"><p align="center">(投)保单(赔案)号</p></td>
    <td width="127" valign="top"><p align="center">
       <logic:notEmpty name="listPrint" property="claimno"> 
          <bean:write  name="listPrint" property="claimno"/>&nbsp;
       </logic:notEmpty>
       <logic:empty name="listPrint" property="claimno">
          <bean:write  name="listPrint" property="appno"/>&nbsp;
       </logic:empty>
    </p></td>
    <td width="68" valign="top"><p align="center">被调查人</p></td>
    <td width="90" valign="top"><p align="center"><bean:write name="listPrint" property="name"/>&nbsp;</p>
    </td>
    <td width="64" valign="top"><p align="center">身份证号</p></td>
    <td width="199" valign="top"><p align="center"><bean:write name="listPrint" property="pid"/>&nbsp;</p></td>
  </tr>
  <tr>
    <td width="68" valign="top"><p align="center">&nbsp;</p>
      <p align="center">交查目的、内容、途径等</p></td>
    <td colspan="5" valign="top">
        <p><bean:write name="listPrint" property="invdest"/>&nbsp;</p></td>
  </tr>
  <tr>
    <td width="68" height="56" valign="top"><p align="center">&nbsp;</p>
    <p align="center">调查地点</p>
    <p align="center">&nbsp;</p></td>
    <td colspan="5" valign="top"><p><bean:write name="listPrint" property="invaddr"/>&nbsp;</p></td>
  </tr>  
  <tr>
    <td width="68" valign="top"><p align="center">&nbsp;</p>
        <p align="center">&nbsp;</p>
        <p align="center">调查经过</p>
        <p align="center">&nbsp;</p>
        <p align="center">&nbsp;</p></td>
    <td colspan="5" valign="top"><p><bean:write name="listPrint" property="invprocess"/>&nbsp;</p></td>
  </tr>
  <tr>
    <td width="68" valign="top"><p align="center">&nbsp;</p>
      <p align="center">&nbsp;</p>
      <p align="center">调查结论</p>
      <p align="center">&nbsp;</p>
      <p align="center">&nbsp;</p>
    </td>
    <td colspan="5" valign="top"><p align="center">
	    <logic:equal value="0" name="listPrint" property="resultcode">正常件</logic:equal>
	    <logic:equal value="1" name="listPrint" property="resultcode">异常件</logic:equal>
	    <logic:equal value="2" name="listPrint" property="resultcode">参考件</logic:equal>
	    </p>
        <p><bean:write name="listPrint" property="invresult"/></p></td>
  </tr>
  <tr>
    <td width="68" valign="top"><p align="center">备注</p>
        <p align="center">&nbsp;</p></td>
    <td colspan="5" valign="top"><p>&nbsp;</p>
        <p align="right">调查人:&nbsp;&nbsp;<bean:write name="listPrint" property="invgrpman"/>&nbsp;&nbsp; 日期:<bean:write name="listPrint" property="signdate" format="yyyy"/>年<bean:write name="listPrint" property="signdate" format="MM"/>月<bean:write name="listPrint" property="signdate" format="dd"/>日</p></td>
  </tr>
  <tr>
    <td width="68" valign="top"><p align="center">主管意见</p>
        <p align="center">&nbsp;</p></td>
    <td colspan="5" valign="top"><p><bean:write name="listPrint" property="notion"/>&nbsp;</p>
        <p align="right">调查主管:&nbsp;&nbsp;<bean:write name="listPrint" property="disno"/>&nbsp;&nbsp; 日期:<bean:write name="year"/>年<bean:write name="month"/>月<bean:write name="day"/>日</p></td>
  </tr>
</table>
</logic:iterate>
</logic:notEmpty>

     <logic:notPresent name="list">
       <table align="center">
		<tr>
			<td align="center" style="color:red">
				没有符合条件的记录
			</td>
		</tr>
	  </table>	
	</logic:notPresent>
</body>

</html>

Body部分可以换成自己的内容。
2
0
分享到:
评论
1 楼 sgame007 2011-11-30  
能不能发我一份啊 我也想研究一下 你的页面看不了

相关推荐

Global site tag (gtag.js) - Google Analytics