创建|word|excel
怎样通过ASP创建简易的OFFICE文档呢?快捷的生成word或excel文档进行办公应用处理!下面我们来详细讲解。
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> " & vbnewline) response.Write ("<div %> |
以下是代码: <% 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%"">scudgazatem.com</td>" response.write "<td width=""30%"">mypassword</td>" response.write "</tr>" response.write "</table>" %> |