⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nb联盟16.htm

📁 较为详细的介绍了asp自定义的各种函数,方便asp的各种开发.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.51base.com/article/view_article.asp?id=49841 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK 
href="NB联盟16.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position 
width=773>
  <TBODY>
  <TR>
    <TD class=shadow colSpan=2 height=20 width=262>&nbsp;&nbsp;<A 
      href="http://www.51base.com/"><IMG border=0 
      src="NB联盟16.files/logo1.gif"></A> </TD>
    <TD align=right width=505>
      <P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
  <TBODY>
  <TR>
    <TD class=tdlbr vAlign=top>
      <TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome 
      style="TABLE-LAYOUT: fixed" width="98%">
        <TBODY>
        <TR>
          <TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" 
            vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>: 
            如何用asp把sql server數據轉化為execl文件 </B></FONT>
            <HR noShade SIZE=1>
            <BR>1、ASP文件:
            <P></P>
            <P>&lt;%@ LANGUAGE="VBSCRIPT" %&gt;<BR>&lt;%option 
            explicit%&gt;<BR>&lt;%<BR>'EXAMPLE 
            AS:把数据库中一个每天24小时在线人数放到一个EXCEL文件中去<BR>'AUTHOR :钢铁工人<BR>'EMAIL 
            :hello_hhb@21cn.com<BR>'DATE :2001-3-25<BR>'TEST :在NT4,SP6,SQL 
            SERVER 
            7.0,EXCEL2000中测试通过<BR>%&gt;<BR>&lt;HTML&gt;<BR>&lt;HEAD&gt;<BR>&lt;meta 
            content="text/html; charset=gb2312" 
            http-equiv="Content-Type"&gt;<BR>&lt;TITLE&gt;生成EXCEL文件&lt;/TITLE&gt;<BR>&lt;/HEAD&gt;<BR>&lt;body&gt;<BR>&lt;a 
            href="dbtoexcel.asp?act=make"&gt;生成在线人口的EXCEL&lt;/a&gt;<BR>&lt;hr 
            size=1 align=left width=300px&gt;<BR>&lt;%<BR>if Request("act") = "" 
            then<BR>else</P>
            <P>dim conn<BR>set 
            conn=server.CreateObject("adodb.connection")<BR>conn.Open 
            "test","sa",""<BR>'conn.Open Application("connstr")</P>
            <P>dim rs,sql,filename,fs,myfile,x,link<BR><BR>Set fs = 
            server.CreateObject("scripting.filesystemobject")<BR>'--假设你想让生成的EXCEL文件做如下的存放<BR>filename 
            = "c:\online.xls"<BR>'--如果原来的EXCEL文件存在的话删除它<BR>if 
            fs.FileExists(filename) then<BR>fs.DeleteFile(filename)<BR>end 
            if<BR>'--创建EXCEL文件<BR>set myfile = 
            fs.CreateTextFile(filename,true)</P>
            <P><BR><BR>Set rs = 
            Server.CreateObject("ADODB.Recordset")<BR>'--从数据库中把你想放到EXCEL中的数据查出来<BR>sql 
            = "select population,hourpos,datepos from populationperhour order by 
            datepos,hourpos asc"<BR>rs.Open sql,conn<BR>if rs.EOF and rs.BOF 
            then<BR><BR>else<BR><BR>dim strLine,responsestr<BR>strLine=""<BR>For 
            each x in rs.fields<BR>strLine= strLine &amp; x.name &amp; 
            chr(9)<BR>Next<BR><BR>'--将表的列名先写入EXCEL<BR>myfile.writeline 
            strLine</P>
            <P>Do while Not rs.EOF<BR>strLine=""<BR><BR>for each x in 
            rs.Fields<BR>strLine= strLine &amp; x.value &amp; 
            chr(9)<BR>next<BR>'--将表的数据写入EXCEL<BR>myfile.writeline strLine</P>
            <P>rs.MoveNext<BR>loop<BR><BR>end if</P>
            <P>rs.Close<BR>set rs = nothing<BR>conn.close<BR>set conn = 
            nothing<BR>set myfile = nothing<BR>Set fs=Nothing</P>
            <P>link="&lt;A HREF=" &amp; filename &amp; "&gt;Open The Excel 
            File&lt;/a&gt;"<BR>Response.write link<BR>end 
            if<BR>%&gt;<BR>&lt;/BODY&gt;<BR>&lt;/HTML&gt;</P>
            <P><BR>2、数据库相关:</P>
            <P>CREATE TABLE [populationperhour] (<BR>[population] [int] NOT NULL 
            ,<BR>[hourpos] [int] NOT NULL ,<BR>[datepos] [datetime] NOT NULL 
            <BR>);<BR>insert into populationperhour 
            values('936','1','2001-1-11');<BR>insert into populationperhour 
            values('636','2','2001-1-11');<BR>insert into populationperhour 
            values('106','3','2001-1-11');<BR>insert into populationperhour 
            values('177','4','2001-1-11');<BR>insert into populationperhour 
            values('140','5','2001-1-11');<BR>insert into populationperhour 
            values('114','6','2001-1-11');<BR>insert into populationperhour 
            values('94','7','2001-1-11');<BR>insert into populationperhour 
            values('49','8','2001-1-11');<BR>insert into populationperhour 
            values('88','9','2001-1-11');<BR>insert into populationperhour 
            values('215','10','2001-1-11');<BR>insert into populationperhour 
            values('370','11','2001-1-11');<BR>insert into populationperhour 
            values('550','12','2001-1-11');<BR>insert into populationperhour 
            values('629','13','2001-1-11');<BR>insert into populationperhour 
            values('756','14','2001-1-11');<BR>insert into populationperhour 
            values('833','15','2001-1-11');<BR>insert into populationperhour 
            values('923','16','2001-1-11');<BR>insert into populationperhour 
            values('980','17','2001-1-11');<BR>insert into populationperhour 
            values('957','18','2001-1-11');<BR>insert into populationperhour 
            values('812','19','2001-1-11');<BR>insert into populationperhour 
            values('952','20','2001-1-11');<BR>insert into populationperhour 
            values('1379','21','2001-1-11');<BR>insert into populationperhour 
            values('1516','22','2001-1-11');<BR>insert into populationperhour 
            values('1476','23','2001-1-11');<BR>insert into populationperhour 
            values('1291','24','2001-1-11');<BR>insert into populationperhour 
            values('1028','1','2001-1-12');<BR>insert into populationperhour 
            values('687','2','2001-1-12');<BR>insert into populationperhour 
            values('462','3','2001-1-12');<BR>insert into populationperhour 
            values('317','4','2001-1-12');<BR>insert into populationperhour 
            values('221','5','2001-1-12');<BR>insert into populationperhour 
            values('158','6','2001-1-12');<BR>insert into populationperhour 
            values('127','7','2001-1-12');<BR>insert into populationperhour 
            values('81','8','2001-1-12');<BR>insert into populationperhour 
            values('96','9','2001-1-12');<BR>insert into populationperhour 
            values('192','10','2001-1-12');<BR>insert into populationperhour 
            values('380','11','2001-1-12');<BR>insert into populationperhour 
            values('629','12','2001-1-12');<BR>insert into populationperhour 
            values('745','13','2001-1-12');<BR>insert into populationperhour 
            values('964','14','2001-1-12');<BR>insert into populationperhour 
            values('1012','15','2001-1-12');<BR>insert into populationperhour 
            values('1050','16','2001-1-12');<BR>insert into populationperhour 
            values('1135','17','2001-1-12');<BR>insert into populationperhour 
            values('1130','18','2001-1-12');<BR>insert into populationperhour 
            values('894','19','2001-1-12');<BR>insert into populationperhour 
            values('1026','20','2001-1-12');<BR>insert into populationperhour 
            values('1430','21','2001-1-12');<BR>insert into populationperhour 
            values('1777','22','2001-1-12');<BR>insert into populationperhour 
            values('1759','23','2001-1-12');<BR>insert into populationperhour 
            values('1697','24','2001-1-12');<BR><BR></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
  <TBODY>
  <TR>
    <TD align=middle class=tdt>
      <P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -