asp/php中利用head匯出xls檔的技巧

<% Response.Buffer = True %>
<html>
<head>
<meta http-equiv=\"Content-Language\" content=\"zh-tw\">
<% Response.ContentType = \"application/vnd.ms-excel\" %>
<% Response.AddHeader \"Content-disposition\", \"attachment;
   filename=DCC_query.xls\" %>

如是, 開啟這網頁後, IE會pop出一個Window 問你對於DCC_query.xls
是要開啟 or 存檔. 而不會開一個嵌在IE裡的EXCEL來跑! ...

ps1. : Response.ContentType = \"application/vnd.ms-excel\"
       是指以ms-excel格式輸出網頁內容
       可善用<Table> 標籤來排板!
ps2. : Response.AddHeader \"Content-disposition\",
                          \"attachment; filename=DCC_query.xls\"
       是指以附件的方式, 檔名為DCC_query.xls 來開起這個網頁!
Share your vote!


Do you like this post?
  • Fascinated
  • Happy
  • Sad
  • Angry
  • Bored
  • Afraid

Leave a Reply

Your email address will not be published. Required fields are marked *


Please help to input verification code