ASP生成EXCEL文件

发布时间:2007-03-07 19:42:00 阅读:1364次

<!--#include file="conn.asp" -->
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta content=Excel.Sheet>
<meta content="Microsoft Excel 11">
<link rel=File-List href="test.files/filelist.xml">
<link rel=Edit-Time-Data href="test.files/editdata.mso">
<link rel=OLE-Object-Data href="test.files/oledata.mso">
<style>
<!--table
 {mso-displayed-decimal-separator:".";
 mso-displayed-thousand-separator:",";}
@page
 {margin:1.0in .75in 1.0in .75in;
 mso-header-margin:.5in;
 mso-footer-margin:.5in;}
tr
 {mso-height-source:auto;
 mso-ruby-visibility:none;}
col
 {mso-width-source:auto;
 mso-ruby-visibility:none;}
br
 {mso-data-placement:same-cell;}
.style0
 {mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 white-space:nowrap;
 mso-rotate:0;
 mso-background-source:auto;
 mso-pattern:auto;
 color:windowtext;
 font-size:12.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 border:none;
 mso-protection:locked visible;
 mso-style-name:常规;
 mso-style-id:0;}
td
 {mso-style-parent:style0;
 padding-top:1px;
 padding-right:1px;
 padding-left:1px;
 mso-ignore:padding;
 color:windowtext;
 font-size:12.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 border:none;
 mso-background-source:auto;
 mso-pattern:auto;
 mso-protection:locked visible;
 white-space:nowrap;
 mso-rotate:0;}
.xl24
 {mso-style-parent:style0;
 font-size:9.0pt;
 font-weight:700;
 text-align:center;
 border:.5pt solid windowtext;
 background:silver;
 mso-pattern:auto none;}
.xl25
 {mso-style-parent:style0;
 font-size:9.0pt;
 font-weight:700;
 text-align:left;
 border:.5pt solid windowtext;
 background:silver;
 mso-pattern:auto none;}
.xl26
 {mso-style-parent:style0;
 color:black;
 font-size:9.0pt;
 border:.5pt solid windowtext;}
.xl27
 {mso-style-parent:style0;
 font-size:11.0pt;
 font-family:Arial, sans-serif;
 mso-font-charset:0;
 border:.5pt solid windowtext;}
.xl28
 {mso-style-parent:style0;
 font-size:9.0pt;
 mso-number-format:"Short Date";
 border:.5pt solid windowtext;}
.xl29
 {mso-style-parent:style0;
 font-size:10.0pt;
 font-weight:700;
 font-family:Arial, sans-serif;
 mso-font-charset:0;
 text-align:center;
 border:.5pt solid windowtext;
 background:silver;
 mso-pattern:auto none;}
ruby
 {ruby-align:left;}
rt
 {color:windowtext;
 font-size:9.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:宋体;
 mso-generic-font-family:auto;
 mso-font-charset:134;
 mso-char-type:none;
 display:none;}
-->
</style>
</head>

<body>
<%
 Response.ContentType="application/msword"
 Response.AddHeader "Content-Disposition","attachment;filename=export" & Year(Now()) & Month(Now()) & Day(Now()) & Hour(Now())  & Minute(Now()) & ".xls"
%>
<table x:str border=0 cellpadding=0 cellspacing=0 width=728 style='border-collapse:
 collapse;table-layout:fixed;width:546pt'>
 <col width=94 style='mso-width-source:userset;mso-width-alt:3008;width:71pt'>
 <col width=375 style='mso-width-source:userset;mso-width-alt:12000;width:281pt'>
 <col width=259 style='mso-width-source:userset;mso-width-alt:8288;width:194pt'>
 <col width=94 style='mso-width-source:userset;mso-width-alt:3008;width:71pt'>
 <tr height=20 style='height:15.0pt'>
  <td height=20 width=94 style='height:15.0pt;width:71pt'>公司ID</td>
  <td width=375 style='width:281pt'>公司名称</td>
  <td width=259 style='border-left:none;width:194pt'>EMAIL</td>
  <td width=94 style='border-left:none;width:71pt'>加入日期</td>
 </tr>
<%
 strSQL="Select *from article order by dt"
 Set rs=conn.Execute(strSql)
 Do Until rs.EOF
%>
 <tr height=21 style='mso-height-source:userset;height:15.75pt'>
  <td height=21 align=right style='height:15.75pt;border-top:none'<%=rs("id")%></td>
  <td style='border-top:none;border-left:none'><%=Trim(rs("comp_name"))%></td>
  <td style='border-top:none;border-left:none'><%=rs("email")%></td>
  <td align=right style='border-top:none;border-left:none'<%=rs("dt")%></td>
 </tr>
<%
 rs.MoveNext
 Loop
%>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
   <td width=94 style='width:71pt'></td>
  <td width=375 style='width:281pt'></td>
  <td width=259 style='width:194pt'></td>
  <td width=94 style='width:71pt'></td>
 </tr>
 <![endif]>
</table>
</body>
</html>

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:ASP生成EXCEL文件 出自老鄢博客 | 欢迎分享