ASP编程具备动态输出任一Office应用程序文件格式的功能。在开始编写代码之前,我们首先需要做的就是设置正确的文件类型,因为浏览器需要知道怎样处理文件。第二步是编辑文件名称,我们可以使用HTML和CSS来创建Word文档或Excel文档的样式。
下面这段例子代码可用于在线创建Word文档。
以下是引用片段:
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"???
response.Write("Dotnetindex.com : Visit Site
" & vbnewline)
response.Write("
We can use HTML codes for word documents
")response.Write (" CSS can be used tooo")
%>
下面这段例子代码可用于在线创建Excel文档。
以下是引用片段:
<%
Response.AddHeader "Content-Disposition", "attachment;filename=members.xls"
Response.ContentType = "application/vnd.ms-excel"
response.write "
Name | "Username | "Password | "
---|---|---|
Scud Block | "scud@gazatem.com | "mypassword | "
%>