Jsp,(word或excel)的结合开发(word或excel)文件的下载

本文档介绍了如何使用JSP结合Word和Excel创建下载文件模板的方法。首先在Word中创建模板并另存为MHT,然后通过编辑MHT文件获取源码。接着在JSP中插入数据库查询,将数据填充到表格中,实现动态从数据库读取数据并生成下载文件的功能。最后,提供了去除JSP痕迹以保存为纯Word或Excel文件的步骤。
摘要由CSDN通过智能技术生成

制作word,excel下载文件模板:

*****************************************************************************

***********author:lenkou*************

****************************************

*****************************************************************************

1。用word创建实例如名称为<example.doc>并在此example.doc中创建一个table(2 row * 2col)

     另存为example.mht

 2。用editplus或Notepad打开example.mht文件可以看到其源码:

MIME-Version: 1.0
Content-Location:
file:///C:/B1542574/file1844.htm
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset="us-ascii"

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office"
xmlns:w=3D"urn:schemas-microsoft-com:office:word"
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 11">
<meta name=3DOriginator content=3D"Microsoft Word 11">
<link rel=3DFile-List href=3D"file1844_files/filelist.xml">
<title>Name1</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>&#65352;&#65370;&#65356;&#65363;&#65363;&#65348;</o:Author>
  <o:LastAuthor>&#65352;&#65370;&#65356;&#65363;&#65363;&#65348;</o:LastAut=
hor>
  <o:Revision>2</o:Revision>
  <o:TotalTime>1</o:TotalTime>
  <o:Created>2008-01-16T06:34:00Z</o:Created>
  <o:LastSaved>2008-01-16T06:34:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>5</o:Words>
  <o:Characters>35</o:Characters>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:CharactersWithSpaces>39</o:CharactersWithSpaces>
  <o:Version>11.5606</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:PunctuationKerning/>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEve=
ry>
  <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=3D"false" LatentStyleCount=3D"156">
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
 {font-family:"MS Mincho";
 panose-1:2 2 6 9 4 2 5 8 3 4;
 mso-font-alt:"MS Mincho";
 mso-font-charset:128;
 mso-generic-font-family:roman;
 mso-font-pitch:fixed;
 mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
@font-face
 {font-family:SimSun;
 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:Century;
 panose-1:2 4 6 4 5 5 5 2 3 4;
 mso-font-charset:0;
 mso-generic-font-family:roman;
 mso-font-pitch:variable;
 mso-font-signature:647 0 0 0 159 0;}
@font-face
 {font-family:"/@SimSun";
 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值