ASP has the ability to dynamically export any Office application file format. Before we start writing code, the first thing we need to do is set the correct file type, because the browser needs to know how to process the file. The second step is to edit the file name, and we can use HTML and CSS to create styles for Word documents or Excel documents.
The following example code can be used to create Word documents online.
以下是引用片段:
<%
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(" response.Write ("<div style=""padding:4px; font:11px arial"">CSS can be used tooo</span>")
%>
The following example code can be used to create an Excel document online.
以下是引用片段:
<%
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>"
%>