在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文件的方法的更多相关文章

  1. word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得

    word和.txt文件转html 及pdf文件, 使用poi jsoup  itext心得本人第一次写博客,有上面不足的或者需要改正的希望大家指出来,一起学习交流讨论.由于在项目中遇到了这一个问题,在 ...

  2. asp.net生成word文档服务器配置

    一.asp.net生成word文档,布署到正式的服务器上就出现           错误:System.Runtime.InteropServices.COMException (0x800A1098 ...

  3. ASP.NET生成WORD文档,服务器部署注意事项

    网上转的,留查备用,我服务器装的office2007所以修改的是Microsoft Office word97 - 2003 文档这一个. ASP.NET生成WORD文档服务器部署注意事项 1.Asp ...

  4. Asp.net读取和写入txt文件方法(实例)!

    Asp.NET读取和写入txt文件方法(实例)! [程序第一行的引入命名空间文件 - 参考] System; using System.Collections; using System.Config ...

  5. python的OS模块生成100个txt文件

    #!/user/bin/env/python35 # -*-coding:utf-8-*- # author:Keekuun """ 问题:生成一个文件夹,文件夹下面生成 ...

  6. ASP输出JSON数据及客户端jQuery处理方法

    首先ASP处理JSON需要json官方提供的JSON For ASP 封装类文件,下载地址:http://code.google.com/p/aspjson/downloads/list 下载最新的J ...

  7. Javascript写入txt和读取txt文件的方法

    文章主要介绍了Javascript写入txt和读取txt文件的方法,需要的朋友可以参考下1. 写入 FileSystemObject可以将文件翻译成文件流. 第一步: 例: 复制代码 代码如下: Va ...

  8. 导出OpenID为txt文件的方法

    导出OpenID为txt文件的方法 public function export(){ $shop = M("Shop"); $arr = $shop->field('ope ...

  9. 2、Python djang 框架下的word Excel TXT Image 等文件的下载

    2.python实现文件下载 (1)方法一.直接用a标签的href+数据库中文件地址,即可下载.缺点:word excel是直接弹框下载,对于image txt 等文件的下载方式是直接在新页面打开. ...

  10. php 备份数据库代码(生成word,excel,json,xml,sql)

    单表备份代码: 复制代码代码如下: <?php class Db { var $conn; function Db($host="localhost",$user=" ...

随机推荐

  1. 简易博客页面小项目 html css

    项目预览 代码 html: <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  2. 什么是Auth模块?(全面了解)

    目录 一:Auth模块 1.什么是Auth模块? 2.Auth模块作用 二:引入Auth模块 1.其实我们在创建好一个Django项目之后直接执行数据库迁移命令会自动生成很多表 2.django在启动 ...

  3. YonBuilder移动开发平台功能大盘点

    YonBuilder是面向企业组织和个人开发者的低代码开发平台,实现无代码.低代码.专业代码开发三种模式.提供元数据驱动和画布构建两种开发方式,通过点击拖拽+自动化代码生成和移动多端编译的技术,与开放 ...

  4. IT编程相关内容汇总 - 进阶者系列 - 学习者系列文章

    笔者工作了十多年了,对于技术也有一定的经验,但是IT编程技术的更新是挺快的,特别是各种框架,各种中间件啥的都涌现出来了.这篇博文笔者打算将IT编程的前端.后端.数据库和移动端做一个博文知识汇总,让阅读 ...

  5. python之路22 hashlib、subprocess、logging模块

    hashlib加密模块 hashlib模块为不同的安全哈希/安全散列(Secure Hash Algorithm)和 信息摘要算法(Message Digest Algorithm)实现了一个公共的. ...

  6. 解决使用linux部署nodejs服务测试代码返回中文是乱码

    今天写了个简单的node.js文件 代码如下 var http = require('http'); http.createServer(function (request, response) { ...

  7. 万字详解,吃透 MongoDB!

    本文已经收录进 JavaGuide(「Java学习+面试指南」一份涵盖大部分 Java 程序员所需要掌握的核心知识.) 少部分内容参考了 MongoDB 官方文档的描述,在此说明一下. MongoDB ...

  8. day15-声明式事务

    声明式事务 1.事务分类 编程式事务 Connection connection = JdbcUtils.getConnection(); try{ //1.先设置事务不要提交 connection. ...

  9. UICC Send USSD 加密信息解析

    已以下指令为例 已知发送 USSD 的格式为:Send USSD aaaxxxxxxxxxxxx*yyyyyyy# ;Fetch:==:SEND USSD SEND 801200001F ASSERT ...

  10. 9月23日内容总结——pycharm的安装与使用、python语法规范与注释、变量和常量、索引取值以及部分数据类型简介

    今日内容总结 目录 今日内容总结 一.pycharm的安装 1.软件介绍 2.正版安装 1.下载软件 2.安装软件 3.其他方法安装(需要先下载相关资源) ①无限试用法 ②傻瓜式激活法 ③淘宝购买 二 ...