簡體   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