ASP生成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.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>" %>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值