table导成execl

zjb_619 2010-05-28 10:24:07
我加上了这句,response.ContentType = "application/vnd.ms-excel"
为什么导出的不是execl,而是下一个asp页面呢?

<% set conn=Server.createObject("ADOdb.CONNECTION")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("scgx.mdb")&";"
%>
<!--#include file="function.asp"-->

<html>
<head>
<title>生产工序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Style.css" type="text/css"><style type="text/css">
<!--
body {
background-color: #D9D8D7;
}
.STYLE2 {font-size: large}
.STYLE9 {font-family: "黑体"}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" backgroud="" >

<%
sql="select * from sccx order by id "
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.Open sql,Conn,1,1
if rs.eof and rs.bof then
response.write("<p align='center'><font color='red'>对不起,暂时无任何记录!</font>")
else
response.ContentType = "application/vnd.ms-excel"
%>
<table border="1" cellpadding="0" colspan="22" cellspacing="0" width="100%" height="79" bordercolor="#999900" bordercolordark="#ffffff" class="out2" align="center">
<tr bgcolor="#CCCCCC">
<td width="7%" height="30" rowspan="2" align="center">工号</td>
<td width="11%" height="30" rowspan="2" align="center">产品名称</td>
<td width="12%" height="30" rowspan="2" align="center">配件名称</td>
<td width="13%" height="30" rowspan="2" align="center">图号</td>
<td width="5%" height="30" rowspan="2" align="center">单位</td>
<td width="8%" height="30" rowspan="2" align="center">台用量</td>
<td width="8%" height="30" rowspan="2" align="center">毛坯库数量</td>
<td height="25" colspan="3" align="center">半成品</td>
<td width="8%" height="30" rowspan="2" align="center">成品库数量</td>
<td width="7%" height="30" rowspan="2" align="center">合计</td>
</tr>
<tr bgcolor="#CCCCCC">
<td width="7%" height="22" align="center">铣床</td>
<td width="7%" height="22" align="center">刨床</td>
<td width="7%" height="22" align="center">钻床</td>
</tr>
<% do while not rs.eof %>
<tr >
<td align="center" height="30"><%=rs("gh")%></td>
<td height="30" align="center"><%=rs("cpmc")%></td>
<td height="30" align="center"><%=rs("pjmc")%></td>
<td height="30" align="center"><%=rs("th")%></td>
<td height="30" align="center"><%=rs("dw")%></td>
<td height="30" align="center"><%=rs("tyl")%></td>
<td height="30" align="center"><%=rs("mpksl")%></td>
<td height="30" align="center"><%=rs("xc")%></td>
<td height="30" align="center"><%=rs("bc")%></td>
<td height="30" align="center"><%=rs("zc")%></td>
<td height="30" align="center"><%=rs("cpksl")%></td>
<td height="30" align="center"><%=rs("hj")%></td>
</tr>
<% rs.movenext
loop
rs.close
conn.close
%>
</table>
<% end if %>
</body>
</html>



...全文
59 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangtututu 2010-05-28
  • 打赏
  • 举报
回复
楼上正解
lzp4881 2010-05-28
  • 打赏
  • 举报
回复
<%
if request.querystring("action")="toExcel" then
Response.ContentType="application/vnd.ms-excel"
Response.AddHeader "content-disposition","attachment;filename=aaa.xls"
end if
%>

<html>
<body>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td > 职务 </td>
<td > 职级 </td>
</tr>
</table>
<input type="button" name="out_excel" onClick="location.href='?action=toExcel'" value="导出到excel">

</body>
</html>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧