仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1735|回复: 19
打印 上一主题 下一主题

[学习教程] ASP教程之若何用asp把sql serverD化execl...

[复制链接]
简单生活 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-16 00:25:34 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关.server   1、ASP文件:

<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit%>
<%
'EXAMPLE AS:把数据库中一个天天24小时在耳目数放到一个EXCEL文件中去
'AUTHOR :钢铁工人
'EMAIL :hello_hhb@21cn.com
'DATE :2001-3-25
'TEST :在NT4,SP6,SQL SERVER 7.0,EXCEL2000中测试经由过程
%>
<HTML>
<HEAD>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<TITLE>生成EXCEL文件</TITLE>
</HEAD>
<body>
<a href="dbtoexcel.asp?act=make">生成在耳目口的EXCEL</a>
<hr size=1 align=left width=300px>
<%
if Request("act") = "" then
else

dim conn
set conn=server.CreateObject("adodb.connection")
conn.Open "test","sa",""
'conn.Open Application("connstr")

dim rs,sql,filename,fs,myfile,x,link

Set fs = server.CreateObject("scripting.filesystemobject")
'--假定你想让生成的EXCEL文件做以下的寄存
filename = "c:\online.xls"
'--假如本来的EXCEL文件存在的话删除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--创立EXCEL文件
set myfile = fs.CreateTextFile(filename,true)



Set rs = Server.CreateObject("ADODB.Recordset")
'--从数据库中把你想放到EXCEL中的数据查出来
sql = "select population,hourpos,datepos from populationperhour order by datepos,hourpos asc"
rs.Open sql,conn
if rs.EOF and rs.BOF then

else

dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next

'--将表的列名先写入EXCEL
myfile.writeline strLine

Do while Not rs.EOF
strLine=""

for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
'--将表的数据写入EXCEL
myfile.writeline strLine

rs.MoveNext
loop

end if

rs.Close
set rs = nothing
conn.close
set conn = nothing
set myfile = nothing
Set fs=Nothing

link="<A HREF=" & filename & ">Open The Excel File</a>"
Response.write link
end if
%>
</BODY>
</HTML>


2、数据库相干:

CREATE TABLE [populationperhour] (
[population] [int] NOT NULL ,
[hourpos] [int] NOT NULL ,
[datepos] [datetime] NOT NULL
);
insert into populationperhour values('936','1','2001-1-11');
insert into populationperhour values('636','2','2001-1-11');
insert into populationperhour values('106','3','2001-1-11');
insert into populationperhour values('177','4','2001-1-11');
insert into populationperhour values('140','5','2001-1-11');
insert into populationperhour values('114','6','2001-1-11');
insert into populationperhour values('94','7','2001-1-11');
insert into populationperhour values('49','8','2001-1-11');
insert into populationperhour values('88','9','2001-1-11');
insert into populationperhour values('215','10','2001-1-11');
insert into populationperhour values('370','11','2001-1-11');
insert into populationperhour values('550','12','2001-1-11');
insert into populationperhour values('629','13','2001-1-11');
insert into populationperhour values('756','14','2001-1-11');
insert into populationperhour values('833','15','2001-1-11');
insert into populationperhour values('923','16','2001-1-11');
insert into populationperhour values('980','17','2001-1-11');
insert into populationperhour values('957','18','2001-1-11');
insert into populationperhour values('812','19','2001-1-11');
insert into populationperhour values('952','20','2001-1-11');
insert into populationperhour values('1379','21','2001-1-11');
insert into populationperhour values('1516','22','2001-1-11');
insert into populationperhour values('1476','23','2001-1-11');
insert into populationperhour values('1291','24','2001-1-11');
insert into populationperhour values('1028','1','2001-1-12');
insert into populationperhour values('687','2','2001-1-12');
insert into populationperhour values('462','3','2001-1-12');
insert into populationperhour values('317','4','2001-1-12');
insert into populationperhour values('221','5','2001-1-12');
insert into populationperhour values('158','6','2001-1-12');
insert into populationperhour values('127','7','2001-1-12');
insert into populationperhour values('81','8','2001-1-12');
insert into populationperhour values('96','9','2001-1-12');
inse</p>  asp,jsp,php是web开发的三大技术,asp简单易用且有microsoft做靠山,jsp功能强大是因为有java支持,php则开源跨平台.在国内,asp应用范围最广,jsp发展势头最猛,php则处于劣势.这可能与公司的支持以及技术的培训有关.
简单生活 该用户已被删除
沙发
 楼主| 发表于 2015-3-28 18:41:22 | 显示全部楼层
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-22 01:39

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表