This article mainly introduces the simplest and most convenient way to export excel files with asp. It can be done with a few lines of code. It is very simple and practical. Friends who need it can refer to it.
Since excel software can recognize data in table format, asp only needs to output the html code in table format, set the contenttype at the same time, and add the response header of saving as an attachment to save the output html code as an xls file.
The source code for asp export excel file is as follows:
Copy the code code as follows:<%
Response.ContentType = application/excel
Response.AddHeader Content-Disposition, attachment;filename=xxxx.xls
%>
<table>
<%while not rs.eof %>
<tr><td>If you have multiple excel cell contents, add td by yourself</td></tr>
<%
rs.movenext
wend
%>
</table>