注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → 编程开发Asp → 文章内容

asp中将table表中的数据成功导成excel做法

作者:IT 来源:不详 发布时间:2007-9-1 23:23:02
我最近刚作了一个项目,该项目的要求是将asp页面中丛书据库中提取的数据直接保存成为excel形式,刚开始我的为此想了好就才最终做了出来,在此和大家共同分享!!
---------------------------------------
脚本如下:<%
dim Rs_code,Sql_code,Rs_date,Sql_date
If Request("Op")="Show" Then
sborder="0"
sbg1="bgcolor=Black"
sbg2="bgcolor=White"
Else
sborder="1"
sbg1=""
sbg2=""
If Request("Op")="Excel" Then
Response.ContentType = "application/msexcel"
Response.AddHeader "Content-disposition","inline; filename=1.xls"
ElseIf Request("Op")="DownLoad" Then
Response.ContentType = "application/msexcel"
FileName="("&Request("sYear")&"-"&Request("sMonth")&")**********(此处为你要做的程序名,自己定义)"
Response.AddHeader "Content-disposition","attachment; filename="&FileName&".xls"
End If
End If
%>
在上层的页面中必须给该页面传送:参数:比如QH_TJ_C_imbark.asp?Op=Show
--------------------------------------------
在要转换成excel输出的程序中必须要在如下部分添加:
<table width="875" border=<%=sborder%> cellspacing="1" cellpadding="1" align="center" <%=sbg1%>>
---------------------------------------------
<tr <%=sbg2%>>
---------------------------------------------
做完以上就绪工作后就可以写你要做的程序了。
http://www.itcnw.com/
  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体
关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved