繁体   English   中英

经典的ASP代码将数据从Access数据库导出到Excel工作表

[英]Classic asp code to export data from Access database to an Excel sheet

我有一个使用经典ASP编码和HTML页面运行的应用程序,而在一个.asp页面中,客户端要求按钮。 单击此按钮时,它必须将Access Table数据库(已在使用中)中存在的所有数据导出到excel工作表中。

您可以生成带有HTML表的xls扩展名的文件,并且Excel将会打开(带有警告)。 例:

text.asp

<html>
<head>
</head>
<body>

<%

    Response.clear
    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader "Content-Disposition", "attachment;filename=ExportedData.xls"
    Response.Write "<table>"
    Response.Write "<tr><th>User</th></tr>"

    set rs = ListUsers()
    if not rs.EOF Then
        Do while not rs.eof
            Response.Write "<tr><td>" + rs("User") + "</td></tr>"
            Rs.movenext
        loop
    end if


    Response.Write "</table>"
    Response.end
%>



</body>
</html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM