精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
返回建站学首页
导航:
建站首页 | 网站设计 | 网站开发 | 网站运营 | 网页软件 | 建站指南 | 搜索优化 | 图像处理 | 视频教程 | 书籍教程 | 建站专题
当前位置:首页>网站开发>ASP教程>正文

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


来源:网页陶吧 时间:07-03-14 点击: 点击这里收藏本文
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>"
%>

  把此文章收藏到:          
广而告之
文章搜索
  • Google JZxue.Com

关于我们 | 联系我们 | 友情链接 | 网站地图
Copyright © 2005 - 2006 建站学 All rights reserved.