• <label id="pxtpz"><meter id="pxtpz"></meter></label>
      1. <span id="pxtpz"><optgroup id="pxtpz"></optgroup></span>

        當前位置:雨林木風下載站 > 技術開發教程 > 詳細頁面

        如何用asp把sqlserver數據轉換為execl文件

        如何用asp把sqlserver數據轉換為execl文件

        更新時間:2022-05-16 文章作者:未知 信息來源:網絡 閱讀次數:

        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');
        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');

        溫馨提示:喜歡本站的話,請收藏一下本站!

        本類教程下載

        系統下載排行

        主站蜘蛛池模板: 亚洲一区视频在线播放| 亚洲乱色伦图片区小说| 亚洲精品在线免费观看视频| 亚洲av第一网站久章草| 男人都懂www深夜免费网站| 日本一区免费电影| 亚洲视频精品在线观看| 亚洲高清免费视频| 在线观看免费成人| 337p日本欧洲亚洲大胆色噜噜| 久久这里只精品99re免费| 亚洲卡一卡2卡三卡4卡无卡三| 一区在线免费观看| 精品久久洲久久久久护士免费| 亚洲色成人网一二三区| 免免费国产AAAAA片| 精品无码一区二区三区亚洲桃色| 一区二区三区免费视频网站| 丝袜熟女国偷自产中文字幕亚洲| 欧美激情综合亚洲一二区| 免费一级毛片不卡不收费| 亚洲中文字幕无码中文| 亚洲一区免费在线观看| 久久久亚洲欧洲日产国码农村| 国产精品偷伦视频免费观看了| 亚洲开心婷婷中文字幕| 中文在线观看免费网站| 亚洲人成人无码网www国产| 成人婷婷网色偷偷亚洲男人的天堂| 午夜国产精品免费观看| 在线91精品亚洲网站精品成人| 麻豆国产入口在线观看免费| 一级美国片免费看| 亚洲高清美女一区二区三区| 永久免费看bbb| 精品视频一区二区三区免费| 久久综合九九亚洲一区| 99re6免费视频| 亚洲另类精品xxxx人妖| 无码专区永久免费AV网站| 亚洲欧美自偷自拍另类视|