复制代码 代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if request("action")=1 then
Response.ContentType="application/ms-excel"
Response.AddHeader "content-disposition","attachment;filename=www.xls"
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
table {
border-top:1px solid #003399;
border-left:1px solid #003399;
}
td {
border-right:1px solid #003399;
border-bottom:1px solid #003399;
}
thead {
background-color:#000066;
font-weight:bold;
padding:5px;
color:#FFFFFF;
}
</style>
<script language="javascript">
function tableToExcel(){
location.href='?action=1';
}
</script>
</head>
<body>
<input type="button" value="导出数据" onclick="tableToExcel()" />
<%
ConnStr="..."
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
set rs = server.CreateObject("adodb.recordset")
rs.open "select top 10 * from [你的表名]",conn,1,1
if not (rs.eof and rs.bof) then
column = rs.fields.count
response.Write("<table cellpadding='0' cellspacing='0'>")
response.Write("<thead><td>序号</td>")
for each f in rs.fields
response.Write("<td>" & f.name & "</td>")
next
response.Write("</thead>")
for j = 1 to rs.recordcount
if j > 5 then '在第五条的时候隐藏数据,经过测试如果是display为none的数据是不会导出来的
response.Write("<tr style='display:none'>")
else
response.Write("<tr>")
end if
response.Write("<td>" & j & "</td>")
for i = 0 to column - 1
response.Write("<td>" & rs(i) & "</td>")
next
response.Write("</tr>")
rs.movenext
next
response.Write("</table>")
end if
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</body>
</html>
相关推荐:
FckEditor 中文配置手册
PPK 谈 JavaScript 的 this 关键字 [翻译]
ASP.NET Cookie 操作实现
Oracle 子程序参数模式,IN,OUT,NOCOPY
通过表单的做为二进制文件上传request.totalbytes提取出上传的二级制数据
php 静态变量的初始化
用Javascript 编写可以缓慢弹出收缩的层
javascript String split方法误操作
JavaScript数组应用 可依次读取的公告栏文字
PHP 字符截取 解决中文的截取问题,不用mb系列
JS溶解形式的文字切换特效
.NET 常用功能和代码小结
Oracle 分析函数RANK(),ROW_NUMBER(),LAG()等的使用方法
Linux下Squid配置详解 Squid代理服务器配置第1/3页
VBS 批量读取文件夹内所有的文本到Excel的脚本
管理员需要参考的当服务器被入侵后的紧急补救方法
jQuery 使用手册(三)
PHP 处理图片的类实现代码
新10种领带的打法 图文教程
Flex 全屏组件 部分全屏的实现代码
Mootools 1.2教程 Fx.Tween的使用
python 快速排序代码
VBScript 算一算你从出生到现在共计多少天
PHP 日常开发小技巧
Serv-U 无法连接到服务器127.0.0.1,端口43958 之解决办法
JavaScript 替换Html标签实现代码
asp.net checkbox 动态绑定id GridView删除提示
Oracle 添加用户并赋权,修改密码,解锁,删除用户的方法
php面向对象全攻略 (七) 继承性
ExtJS Grid使用SimpleStore、多选框的方法
Sql server2005 优化查询速度50个方法小结
javascript Range对象跨浏览器常用操作第1/2页
XHTML下,JS浮动代码失效的问题
asp.net *.ashx类型的文件使用说明
JQuery SELECT单选模拟jQuery.select.js
Asp.net treeview实现无限级树实现代码
VBS 脚本不能运行 提示Windows无法访问指定设备路径或文件
SQLSERVER中union,cube,rollup,cumpute运算符使用说明
SQLServe 重复行删除方法
Flex 3 布局容器学习笔记 整理
ASP 高级模板引擎实现类
executesql 存储过程
php+javascript的日历控件
APACHE 配置文件中文版 httpd.conf FOR Apache 2.2.13
jquery (show,fadeOut,Animate)简单效果
Apache下禁止特定目录执行PHP 提高服务器安全性
Mootools 1.2教程 正则表达式
简单实用的HTML到UBB转换脚本工具实现说明
mySQL 延迟 查询主表
将jQuery应用于login页面的问题及解决