asp導(dǎo)出excel文件最簡單方便的方法

字號:


    這篇文章主要介紹了asp導(dǎo)出excel文件最簡單方便的方法,幾行代碼就可以搞定,非常簡單實用,需要的朋友可以參考下
    由于excel軟件能識別table格式的數(shù)據(jù),所以asp只需要輸出table格式的html代碼,同時設(shè)置好contenttype,增加保存為附件的響應(yīng)頭即可將輸出的html代碼保存為xls文件。
    asp導(dǎo)出excel文件源代碼如下:
    代碼如下:
    <%
    Response.ContentType = "application/excel"
    Response.AddHeader "Content-Disposition", "attachment;filename=""xxxx.xls"""
    %>
    <table>
    <%while not rs.eof %>
    <tr><td>你的excel單元格內(nèi)容,有多個自己增加td</td></tr>
    <%
    rs.movenext
    wend
    %>
    </table>