【ASP】Table匯出Excel

用最簡單的方式, 將Table內容匯出到Excel中, 以下範例參考之 !

<%
Response.Clear()
Response.ContentType="application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;FileName=people.xls"

result="<html>"
result=result & "<body>"
result=result & "<table border='1'  width='300'>"
result=result & "<tr><td width='25%'>編號</td><td width='25%'>姓名</td><td width='50%'>出生地</td></tr>"
result=result & "<tr><td width='25%'>A01</td><td width='25%'>Amy</td><td width='50%'>台北市</td></tr>"
result=result & "<tr><td width='25%'>A02</td><td width='25%'>Bob</td><td width='50%'>台中市</td></tr>"
result=result & "<tr><td width='25%'>A03</td><td width='25%'>CoCo</td><td width='50%'>高雄市</td></tr></table>"
result=result &"</body></html>"
response.Write result

%>

匯出到Excel畫面


留言

這個網誌中的熱門文章

【ASP】日期轉換(西元<-->民國)

【VB】使用NPOI元件來匯出Excel--DataTableToExcel

【SQL】符號切割字串變成多欄