使用ASP將MSSQL的資料匯入Excel檔案
如何使用ASP將MSSQL指定的資料匯入到Excel裡面?
範例語法如下(下列語法僅片段語法):
excel.htm
<a href="excel.asp" style="text-decoration:none" title="匯出Excel檔">匯出<img src="../images/Excel-32-d.gif" border="0" alt="匯出Excel檔">檔</a>
excel.asp
<%
Response.AddHeader "Content-Disposition","attachment;filename=BikeMember.xls"
Response.ContentType = "application/vnd.ms-excel"
%>
<html>
<body>
<table width="100%">
<tr>
<td align="center" width="60">編號</td>
<td align="center" width="60">姓名</td>
</tr>
<%
ShowOnePage rs, Page
Sub ShowOnePage( rs, Page )
sql="Select * from Member order by ID"
Set rs=SetRsStatic(sql)
For iPage = 1 To rs.RecordCount
If rs.EOF Then Exit For
RsToViewMsg rs
rs.MoveNext
If rs.EOF Then Exit For
Next
End Sub
Sub RsToViewMsg( rs )
number=rs("ID")
%>
<tr bgcolor="<%=TrBgColor%>">
<td align="center"><%
if len(number)>0 then
response.write (number)
else
response.write " "
end if%>
</td>
<td align="center"><%=rs("Name")%></td>
</tr>
<%End Sub%>
</table>
</body>
</html>
參考或是複製語法時,別忘了留個言喔 ^ ^ ~