ASP生成WORD文档或EXCEL文档
2008-07-08 14:10
447 查看
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.moouoo.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>"
%>
下面这段例子代码可用于在线创建Word文档。
以下是引用片段:
<%
Response.ContentType = "application/msword"
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"
response.Write("Dotnetindex.com : <a href=http://www.moouoo.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>"
%>
相关文章推荐
- 用ASP生成Word、Excel和Txt文档
- 在asp.net中无需服务器安装word,利用xml生成word文档
- asp.net 调用 生成word 后excel 权限不足的问题的一些使用经验
- ASP 把数据库内容生成Word文档保存到目录下
- Asp.net动态生成Word文档并填充数据 转
- JSP生成WORD文档,EXCEL文档及PDF文档的方法
- Asp.Net输出指定内容的Word、Excel、TXT、HTM等类型的文档
- C#也能动态生成Word文档并填充数据, 导出EXCEL 方法
- 使用ASP.NET生成Word文档并直接下载
- 在asp.net生成的word文档中插入图片
- asp.net下用Aspose.Words for .NET动态生成word文档中的图片或水印的方法
- ASP.NET生成WORD文档服务器部署注意事项
- 在asp.net生成的word文档中插入图片(转)
- ASP.NET生成WORD文档服务器部署注意事项
- 从数据库导出数据生成word或excel文档
- ASP输出文件为word及excel文档
- Asp生成Word文档
- asp生成和导出excel和word数据源码和代码,简单好用(已经测试可以用)
- Asp.net动态生成Word文档并填充数据 转
- [转]Asp.Net页面输出到WORD、EXCEL、TXT、HTM等类型的文档