网易

行情搜索:

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

2007-03-13 10:17:43 来源: 网页陶吧  网友评论 0 进入论坛

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%"">scud@gazatem.com</td>"
response.write "<td width=""30%"">mypassword</td>"
response.write "</tr>"
response.write "</table>"
%>

     原文地址:

     http://www.dotnetindex.com/articles/3892_Creating_Word_Files_Online.asp

     http://www.dotnetindex.com/articles/3893_Creating_Excel_Files_Online.asp

>>>更多精彩访问:网易学院

陈刚

网易科技,更多精彩在首页,
我也评两句
我的灌水记录
匿名发表

 
精彩推荐

今日网易科技看点


商业推荐

排行榜

今日网易财经看点


主编信箱 频道热线电话 给网易提意见 
About NetEase - 公司简介 - 联系方法 - 招聘信息 - 客户服务 - 相关法律 - 网络营销 - 网站地图
网易公司版权所有
©1997-2009