当前位置: 首页 > 图文教程 > 网络编程 > ASP > 技巧:用ASP在线创建Word与Excel文档

ASP
ASP实现表单中容量大的数据的提交方法
强烈推荐ASP初学者观看:常用ASP技术
认真学习ASP内置对象Session的应用
asp函数转换xml中的实体字符[转义符]
ASP防止重复多次提交表单的方法
ASP处理XSLT转换XML的实现
ASP中将Excel数据导入到Access
[推荐]ASP 编程中 20 个非常有用的例子
[推荐]每个ASP程序员必备的知识
[推荐]ASP初学者常犯的几个错误
解决杀毒软件误删asp文件的方法
用VB编写ActiveX DLL实现ASP编程
asp.net结合js的网页打印程序
ASP网站远程客户实现EXCEL打印功能
ASP程序中使用断开的数据记录集
利用ASP发送和接收XML数据的处理方法
20种看ASP程序源码的方法及工具
ASP技巧:禁用FileSystemObject组件
在ASP中使用SQL语句:开始执行
ASP编写计数器的优化方法

技巧:用ASP在线创建Word与Excel文档


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 55 ::
收藏到网摘: n/a

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%"">[email protected]</td>"
response.write "<td width=""30%"">mypassword</td>"
response.write "</tr>"
response.write "</table>"
%>