日本国产亚洲-日本国产一区-日本国产一区二区三区-日本韩国欧美一区-日本韩国欧美在线-日本韩国欧美在线观看

當(dāng)前位置:雨林木風(fēng)下載站 > 技術(shù)開(kāi)發(fā)教程 > 詳細(xì)頁(yè)面

將數(shù)據(jù)庫(kù)里面的內(nèi)容生成EXCEL

將數(shù)據(jù)庫(kù)里面的內(nèi)容生成EXCEL

更新時(shí)間:2022-05-10 文章作者:未知 信息來(lái)源:網(wǎng)絡(luò) 閱讀次數(shù):

1、ASP文件:

<%@ LANGUAGE="VBSCRIPT" %>
<%option explicit%>
<%
'EXAMPLE AS:把數(shù)據(jù)庫(kù)中一個(gè)每天24小時(shí)在線人數(shù)放到一個(gè)EXCEL文件中去
'AUTHOR    :鋼鐵工人
'EMAIL     :hello_hhb@21cn.com
'DATE      :2001-3-25
'TEST      :在NT4,SP6,SQL SERVER 7.0,EXCEL2000中測(cè)試通過(guò)
%>
<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")
  '--假設(shè)你想讓生成的EXCEL文件做如下的存放
  filename = "c:\online.xls"
  '--如果原來(lái)的EXCEL文件存在的話刪除它
  if fs.FileExists(filename) then
    fs.DeleteFile(filename)
  end if
  '--創(chuàng)建EXCEL文件
  set myfile = fs.CreateTextFile(filename,true)


  
  Set rs = Server.CreateObject("ADODB.Recordset")
  '--從數(shù)據(jù)庫(kù)中把你想放到EXCEL中的數(shù)據(jù)查出來(lái)
  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
    
      '--將表的列名先寫(xiě)入EXCEL
      myfile.writeline strLine

      Do while Not rs.EOF
      strLine=""
     
      for each x in rs.Fields
        strLine= strLine & x.value & chr(9)
      next
      '--將表的數(shù)據(jù)寫(xiě)入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、數(shù)據(jù)庫(kù)相關(guān):

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');
insert into populationperhour values('192','10','2001-1-12');
insert into populationperhour values('380','11','2001-1-12');
insert into populationperhour values('629','12','2001-1-12');
insert into populationperhour values('745','13','2001-1-12');
insert into populationperhour values('964','14','2001-1-12');
insert into populationperhour values('1012','15','2001-1-12');
insert into populationperhour values('1050','16','2001-1-12');
insert into populationperhour values('1135','17','2001-1-12');
insert into populationperhour values('1130','18','2001-1-12');
insert into populationperhour values('894','19','2001-1-12');
insert into populationperhour values('1026','20','2001-1-12');
insert into populationperhour values('1430','21','2001-1-12');
insert into populationperhour values('1777','22','2001-1-12');
insert into populationperhour values('1759','23','2001-1-12');
insert into populationperhour values('1697','24','2001-1-12');



溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!

本類教程下載

系統(tǒng)下載排行

主站蜘蛛池模板: 六月丁香综合网 | 久热久草 | 亚洲毛片在线免费观看 | 毛片视频免费网站 | 中文字幕在线免费观看视频 | 日本一级毛片片在线播放 | 欧美一区二区免费 | 动漫精品一区二区三区视频 | 2021国内精品久久久久久影院 | 乱码中文在线观看 | 一区二区三区在线 | 欧 | 成 人免费va视频 | 日韩欧美精品有码在线观看 | 久久综合噜噜激激的五月天 | 精品四虎 | 欧美第3页| 亚洲水蜜桃久久综合网站 | 国产欧美精品午夜在线播放 | 亚洲啪在线 | 免费高清一级欧美片在线观看 | 免费99精品国产自在现线观看 | wwww.xxxx日本| 日本边摸边吃奶边做免费视频 | 国产黄视频网站 | www.夜夜骑.com| 狠狠色伊人亚洲综合第8页 狠狠色伊人亚洲综合网站色 | 欧美综合亚洲图片综合区 | 亚洲国产精品xo在线观看 | 水蜜桃网 | 日韩美a一级毛片 | 欧美一区1区三区3区公司 | 91久久精品国产一区二区 | 亚洲精品高清国产一久久 | 盗摄偷拍a在线观看 | 天天躁天天弄天天爱 | 亚洲欧洲国产成人综合一本 | 国产在线一91区免费国产91 | 激情欧美日韩一区二区 | 欧美成人免费毛片 | 天天摸天天操天天干 | 欧美视频一二三区 |