ASP输出生成Word 、Excel、Txt文件的方法
在ASP中生成Word文件、Excel文件和Txt文件,参考了微软的官方文档,自己简单弄了下,基本可以实现了,不足之处,望指导!下面言归正传。
1、用ASP生成Word文档,代码示例:
01
<%
02
Response.ContentType = "application/msword"
03
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc"
04
Response.Write("欢迎来到源码爱好者!<br>" & vbnewline)
05
Response.Write("<h1>用ASP生成Word文档的示例</h1>")
06
response.write "<table width=""100%"" border=""1"" >"
07
response.write "<tr>"
08
response.write "<th width=""40%""><b>Name</b></th>"
09
response.write "<th width=""30%""><b>Username</b></th>"
10
response.write "<th width=""30%""><b>Password</b></th>"
11
response.write "</tr>"
12
response.write "<tr>"
13
response.write "<td width=""40%"">源码爱好者</td>"
14
response.write "<td width=""30%"">user</td>"
15
response.write "<td width=""30%"">mypassword</td>"
16
response.write "</tr>"
17
response.write "</table>"
18
%>
用这种方法生成的Word文档,有时候会出现一个提示:“Microsoft Office Word 需要转换器以正确显示该文件。这项功能目前尚未安装,是否现在安装?”,这时候重新安装SKU011.CAB就可以了,原因不明。
2、ASP生成Excel文档:
01
<%
02
Response.AddHeader "Content-Disposition", "attachment;filename=members.xls"
03
Response.ContentType = "application/vnd.ms-excel"
04
response.write "<table width=""100%"" border=""1"" >"
05
response.write "<tr>"
06
response.write "<th width=""40%""><b>教程文章</b></th>"
07
response.write "<th width=""30%""><b>Username</b></th>"
08
response.write "<th width=""30%""><b>Password</b></th>"
09
response.write "</tr>"
10
response.write "<tr>"
11
response.write "<td width=""40%"">源码爱好者</td>"
12
response.write "<td width=""30%"">user</td>"
13
response.write "<td width=""30%"">mypassword</td>"
14
response.write "</tr>"
15
response.write "</table>"
16
%>
3、ASP生成Txt文档,这个最简单,用Fso就可以:
view sourceprint?
1
<%
2
set objFso = server.createobject("scripting.filesystemobject")
3
set objFile = objFso.CreateTextFile("sample.txt", false)
4
objFile.write "这是一个生成txt文本的演示文档"
5
objFile.close
6
set objFile = nothing
7
objFso = nothing
8
%>
在ASP中生成Word文件、Excel文件和Txt文件,参考了微软的官方文档,自己简单弄了下,基本可以实现了,不足之处,望指导!下面言归正传。
1、用ASP生成Word文档,代码示例:
01 |
<% |
02 |
Response.ContentType = "application/msword" |
03 |
Response.AddHeader "Content-Disposition", "attachment;filename=NAME.doc" |
04 |
Response.Write("欢迎来到源码爱好者!<br>" & vbnewline) |
05 |
Response.Write("<h1>用ASP生成Word文档的示例</h1>") |
06 |
response.write "<table width=""100%"" border=""1"" >" |
07 |
response.write "<tr>" |
08 |
response.write "<th width=""40%""><b>Name</b></th>" |
09 |
response.write "<th width=""30%""><b>Username</b></th>" |
10 |
response.write "<th width=""30%""><b>Password</b></th>" |
11 |
response.write "</tr>" |
12 |
response.write "<tr>" |
13 |
response.write "<td width=""40%"">源码爱好者</td>" |
14 |
response.write "<td width=""30%"">user</td>" |
15 |
response.write "<td width=""30%"">mypassword</td>" |
16 |
response.write "</tr>" |
17 |
response.write "</table>" |
18 |
%> |
用这种方法生成的Word文档,有时候会出现一个提示:“Microsoft Office Word 需要转换器以正确显示该文件。这项功能目前尚未安装,是否现在安装?”,这时候重新安装SKU011.CAB就可以了,原因不明。
2、ASP生成Excel文档:
01 |
<% |
02 |
Response.AddHeader "Content-Disposition", "attachment;filename=members.xls" |
03 |
Response.ContentType = "application/vnd.ms-excel" |
04 |
response.write "<table width=""100%"" border=""1"" >" |
05 |
response.write "<tr>" |
06 |
response.write "<th width=""40%""><b>教程文章</b></th>" |
07 |
response.write "<th width=""30%""><b>Username</b></th>" |
08 |
response.write "<th width=""30%""><b>Password</b></th>" |
09 |
response.write "</tr>" |
10 |
response.write "<tr>" |
11 |
response.write "<td width=""40%"">源码爱好者</td>" |
12 |
response.write "<td width=""30%"">user</td>" |
13 |
response.write "<td width=""30%"">mypassword</td>" |
14 |
response.write "</tr>" |
15 |
response.write "</table>" |
16 |
%> |
3、ASP生成Txt文档,这个最简单,用Fso就可以:
1 |
<% |
2 |
set objFso = server.createobject("scripting.filesystemobject") |
3 |
set objFile = objFso.CreateTextFile("sample.txt", false) |
4 |
objFile.write "这是一个生成txt文本的演示文档" |
5 |
objFile.close |
6 |
set objFile = nothing |
7 |
objFso = nothing |
8 |
%> |
ASP输出生成Word 、Excel、Txt文件的方法的更多相关文章
- word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得
word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得本人第一次写博客,有上面不足的或者需要改正的希望大家指出来,一起学习交流讨论.由于在项目中遇到了这一个问题,在 ...
- asp.net生成word文档服务器配置
一.asp.net生成word文档,布署到正式的服务器上就出现 错误:System.Runtime.InteropServices.COMException (0x800A1098 ...
- ASP.NET生成WORD文档,服务器部署注意事项
网上转的,留查备用,我服务器装的office2007所以修改的是Microsoft Office word97 - 2003 文档这一个. ASP.NET生成WORD文档服务器部署注意事项 1.Asp ...
- Asp.net读取和写入txt文件方法(实例)!
Asp.NET读取和写入txt文件方法(实例)! [程序第一行的引入命名空间文件 - 参考] System; using System.Collections; using System.Config ...
- python的OS模块生成100个txt文件
#!/user/bin/env/python35 # -*-coding:utf-8-*- # author:Keekuun """ 问题:生成一个文件夹,文件夹下面生成 ...
- ASP输出JSON数据及客户端jQuery处理方法
首先ASP处理JSON需要json官方提供的JSON For ASP 封装类文件,下载地址:http://code.google.com/p/aspjson/downloads/list 下载最新的J ...
- Javascript写入txt和读取txt文件的方法
文章主要介绍了Javascript写入txt和读取txt文件的方法,需要的朋友可以参考下1. 写入 FileSystemObject可以将文件翻译成文件流. 第一步: 例: 复制代码 代码如下: Va ...
- 导出OpenID为txt文件的方法
导出OpenID为txt文件的方法 public function export(){ $shop = M("Shop"); $arr = $shop->field('ope ...
- 2、Python djang 框架下的word Excel TXT Image 等文件的下载
2.python实现文件下载 (1)方法一.直接用a标签的href+数据库中文件地址,即可下载.缺点:word excel是直接弹框下载,对于image txt 等文件的下载方式是直接在新页面打开. ...
- php 备份数据库代码(生成word,excel,json,xml,sql)
单表备份代码: 复制代码代码如下: <?php class Db { var $conn; function Db($host="localhost",$user=" ...
随机推荐
- JavaScript入门⑩-ES6归纳总结
JavaScript入门系列目录 JavaScript入门①-基础知识筑基 JavaScript入门②-函数(1)基础{浅出} JavaScript入门③-函数(2)原理{深入}执行上下文 JavaS ...
- 分布式计算MapReduce究竟是怎么一回事?
前言 如果要对文件中的内容进行统计,大家觉得怎么做呢?一般的思路都是将不同地方的文件数据读取到内存中,最后集中进行统计.如果数据量少还好,但是面对海量数据.大数据的场景这样真的合适吗?不合适的话,那有 ...
- 《HTTP权威指南》– 6.代理
代理的概念: Web代理服务器是网络的中间实体.位于客户端和服务器之间,扮演"中间人"的角色,在各端点之间来回传送HTTP报文. 私有和共享代理: 代理服务器可以是某个客户端专用的 ...
- java的基本数据类型自动转换
本文主要内容阐明java的自动数据类型转换 首先明确,数据总是由精度低到精度高方向转换 public class AutoConvert { public static void main(Strin ...
- json 提取器将提取的所有id拼接成字符串
1.添加json提取器,提取所有的id 2.添加调试后置处理器查看buildid_ALL值以及类型 当需要将提取的id拼接成字符串时,此时使用json提取器并勾选Compute concatenati ...
- vue 单独封装分页组件
一.在components文件夹下新建 pagination.vue <template> <div class="page-wrap"> <ul&g ...
- [MySQL] 索引的使用、SQL语句优化策略
目录 索引 什么是索引 索引的创建与删除 创建索引 删除索引 索引的使用 使用explain分析SQL语句 最佳左前缀 索引覆盖 避免对索引列进行额外运算 SQL语句优化 小表驱动大表 索引 什么是索 ...
- Codeforces Hello 2023 CF 1779 A~F 题解
点我看题 A. Hall of Fame 先把不用操作就合法的情况判掉.然后发现交换LL,RR,RL都是没用的,只有交换LR是有用的,这样可以照亮相邻的两个位置.所以我们就是要找到一个位置i,满足\( ...
- vulnhub靶场之IA: KEYRING (1.0.1)
准备: 攻击机:虚拟机kali.本机win10. 靶机:IA: KEYRING (1.0.1),下载地址:https://download.vulnhub.com/ia/keyring-v1.01.o ...
- (23)go-micro微服务客户端开发(使用负载均衡)
目录 一 main.go开发 二 客户端代码开发: 三 客户端测试功能 1.发送注册邮件 2.实现注册功能 3.查询用户功能 四 运行项目 五 最后 一 main.go开发 至此,咱们的项目服务端代码 ...