asp页面导出excel数据表 5
asp查询页面查询出的数据如何通过一个“导出数据”连接,导出excel数据到用户自定义位置,最好给个代码实例...
asp查询页面查询出的数据如何通过一个“导出数据”连接,导出excel数据到用户自定义位置,最好给个代码实例
展开
展开全部
乐于分享
<%
Response.ContentType ="application/vnd.ms-excel"
Response.Addheader "Content-Disposition", "attachment;Filename=list.xls"
Dim rs, sql
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT ..."
rs.open sql,conn,1,3
'Response.Write(sql)
if not(rs.eof or rs.bof) then
Response.Write("<table>")
Response.Write("<tr>")
Response.Write("<td>编号</td>")
Response.Write("<td>门牌号</td>")
Response.Write("<td>姓名</td>")
Response.Write("<td>性别</td>")
Response.Write("<td>身份证号码</td>")
Response.Write("<td>联系电话</td>")
Response.Write("</tr>")
while not rs.eof
Response.Write("<tr>")
Response.Write("<td>"& rs(0) &"</td>")
Response.Write("<td>"& rs(5) &"</td>")
Response.Write("<td>"& rs(1) &"</td>")
Response.Write("<td>"& rs(2) &"</td>")
Response.Write("<td>'"& rs(3) &"</td>")
Response.Write("<td>'"& rs(4) &"</td>")
Response.Write("</tr>")
rs.movenext
wend
Response.Write("</table>")
end if
<%
Response.ContentType ="application/vnd.ms-excel"
Response.Addheader "Content-Disposition", "attachment;Filename=list.xls"
Dim rs, sql
set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT ..."
rs.open sql,conn,1,3
'Response.Write(sql)
if not(rs.eof or rs.bof) then
Response.Write("<table>")
Response.Write("<tr>")
Response.Write("<td>编号</td>")
Response.Write("<td>门牌号</td>")
Response.Write("<td>姓名</td>")
Response.Write("<td>性别</td>")
Response.Write("<td>身份证号码</td>")
Response.Write("<td>联系电话</td>")
Response.Write("</tr>")
while not rs.eof
Response.Write("<tr>")
Response.Write("<td>"& rs(0) &"</td>")
Response.Write("<td>"& rs(5) &"</td>")
Response.Write("<td>"& rs(1) &"</td>")
Response.Write("<td>"& rs(2) &"</td>")
Response.Write("<td>'"& rs(3) &"</td>")
Response.Write("<td>'"& rs(4) &"</td>")
Response.Write("</tr>")
rs.movenext
wend
Response.Write("</table>")
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在你显示记录集的页面前面加上:
<%
nowfilename=replace(replace(replace(now,":","")," ",""),"/","")
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "inline; filename = "&nowfilename&".xls"
%>
<%
nowfilename=replace(replace(replace(now,":","")," ",""),"/","")
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "content-disposition", "inline; filename = "&nowfilename&".xls"
%>
追问
查询页面已经显示的了一个表格,希望把这个表格的内容导出为excel文件。设想是这样的,在asp显示页面中,在表格上方有“导出为excel”几个字,点击这里是可以到处为excel文件,导出的位置可以选择。能讲详细一点么?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询