用ASP在线创建Word与Excel文档

来源:dotnetindex.com 时间:2008-07-20 19:17:00 

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>" 
%>
标签:word,excel.asp
0
投稿

猜你喜欢

  • PHP设计模式之模板方法模式Template Method Pattern详解

    2023-05-25 00:24:26
  • 实例操作MySQL短链接

    2024-01-16 00:07:42
  • 得到字符串真实长度和取固定长度的字符串函数

    2008-10-06 13:12:00
  • XMLHttpRequest Level 2 使用指南

    2024-04-18 10:49:50
  • 详解Windows Server 2012下安装MYSQL5.7.24的问题

    2024-01-27 10:20:37
  • python实现棋盘覆盖问题及可视化

    2021-04-17 02:10:29
  • JavaScript原生对象常用方法总结(推荐)

    2024-05-05 09:15:20
  • Python实现将数据库一键导出为Excel表格的实例

    2024-01-19 19:47:27
  • 十万条Access数据表分页的两个解决方法

    2008-05-23 18:24:00
  • Bootstrap编写一个兼容主流浏览器的受众巨幕式风格页面

    2024-05-02 17:31:43
  • 软件与网站设计的区别

    2009-05-04 14:30:00
  • 详解python中的异常捕获

    2021-11-21 00:52:20
  • 解决Jrebel用户名中文导致用不了的问题

    2023-04-10 05:20:15
  • python包和文件夹有的区别点总结

    2022-05-09 11:59:01
  • 空间session失效过快的解决办法

    2010-09-15 10:01:00
  • Numpy数组转置的两种实现方法

    2023-01-22 16:36:54
  • RSS2.0规范中文版

    2008-06-25 13:53:00
  • php 图片上添加透明度渐变的效果

    2023-10-23 09:00:02
  • Go语言中反射的正确使用

    2024-02-01 16:31:57
  • chatgpt 1020 错误码成功解决的三种方案(推荐)

    2023-02-03 17:33:28
  • asp之家 网络编程 m.aspxhome.com