close

ASP具備動態輸出任一Office應用程序文件格式的功能。在開始編寫代碼之前,我們首先需要做的就是設置正確的文件類型,因為瀏覽器需要知道如何處理文件。第二步是編輯文件名稱,我們可以使用HTML和CSS來創建Word文檔或Excel文檔的樣式。


     下面這段例子代碼可用於在線創建Word文檔。





以下是引用片段:
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"??? 
response.Write("Dotnetindex.com : <a href=""http://www.dotnetindex.com"">Visit Site</a><br>" & vbnewline)
response.Write("<h1>We can use HTML codes for word documents</h1>")
response.Write ("<div style=""padding:4px; font:11px arial"">CSS can be used tooo</span>")
%>

     下面這段例子代碼可用於在線創建Excel文檔。





以下是引用片段:
<%
Response.AddHeader "Content-Disposition", "attachment;filename=members.xls"
Response.ContentType = "application/vnd.ms-excel"
response.write "<table width="100%" border="1" >"
response.write "<tr>"
response.write "<th width=""40%""><b>Name</b></th>"
response.write "<th width=""30%""><b>Username</b></th>"
response.write "<th width=""30%""><b>Password</b></th>"
response.write "</tr>"
response.write "<tr>"
response.write "<td width=""40%"">Scud Block</td>"
response.write "<td width=""30%"">scud@gazatem.com</td>"
response.write "<td width=""30%"">mypassword</td>"
response.write "</tr>"
response.write "</table>"
%>




arrow
arrow
    全站熱搜
    創作者介紹
    創作者 itest8 的頭像
    itest8

    itest8的部落格

    itest8 發表在 痞客邦 留言(0) 人氣()