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

📄 asp如何操作excel,读取表格.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=74344 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK 
href="NB联盟32.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联盟32.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如何操作excel,读取表格!!! </B></FONT>
            <HR noShade SIZE=1>
            <BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>&lt;% 
            &nbsp;<BR>'=====================ASP读取EXCEL注事项=========================== 
            &nbsp;<BR>'i)将Excel97或Excel2000生成的XLS文件(book)看成一个数据库,其中的每一个工作表(sheet)看成数据库表 
            &nbsp;<BR>'ii)ADO假设Excel中的第一行为字段名.所以你定义的范围中必须要包括第一行的内容 
            &nbsp;<BR>'iii)Excel中的行标题(即字段名)不能够包含数字. 
            &nbsp;Excel的驱动在遇到这种问题时就会出错的。例如你的行标题名为“F1” 
            &nbsp;<BR>'iiii)如果你的Excel电子表格中某一列同时包含了文本和数字的话,那么Excel的ODBC驱动将不能够正常, 
            &nbsp;处理这一行的数据类型,你必须要保证该列的数据类型一致 &nbsp;<BR>'E-MAIL:Kaxue@Hotmail.com 
            &nbsp;QQ:484110 &nbsp;HOMEPAGE:www.Flyday.net 
            &nbsp;<BR>'整理时间:Thursday, &nbsp;May &nbsp;23, &nbsp;2002 &nbsp;5:54 
            &nbsp;PM &nbsp;WIN2000SERVER+IIS5 &nbsp;测式通过 
            &nbsp;<BR>'=================================================================== 
            &nbsp;<BR>&nbsp;Dim &nbsp;Conn,Driver,DBPath,Rs &nbsp;<BR>&nbsp;' 
            &nbsp;建立Connection对象 &nbsp;<BR>&nbsp;Set &nbsp;Conn &nbsp;= 
            &nbsp;Server.CreateObject("ADODB.Connection") &nbsp;<BR>&nbsp;Driver 
            &nbsp;= &nbsp;"Driver={Microsoft &nbsp;Excel &nbsp;Driver 
            &nbsp;(*.xls)};" &nbsp;<BR>&nbsp;DBPath &nbsp;= &nbsp;"DBQ=" 
            &nbsp;&amp; &nbsp;Server.MapPath( &nbsp;"test.xls" &nbsp;) 
            &nbsp;<BR>&nbsp;'调用Open &nbsp;方法打开数据库 &nbsp;<BR>&nbsp;Conn.Open 
            &nbsp;Driver &nbsp;&amp; &nbsp;DBPath &nbsp;<BR>&nbsp;'DSN连接方式 
            &nbsp;<BR>&nbsp;'Conn.Open &nbsp;"Dsn=test" &nbsp;<BR>&nbsp;'注意 
            &nbsp;表名一定要以下边这种格试 &nbsp;"[表名$]" &nbsp;书写 
            &nbsp;<BR>&nbsp;Sql="Select &nbsp;* &nbsp;From &nbsp;[Sheet1$] 
            &nbsp;where &nbsp;序号=0" &nbsp;<BR>&nbsp;Set 
            &nbsp;Rs=Conn.Execute(Sql) &nbsp;<BR>&nbsp;IF &nbsp;Rs.Eof &nbsp;And 
            &nbsp;Rs.Bof &nbsp;Then &nbsp;<BR>&nbsp; &nbsp;Response.write 
            &nbsp;"没有找到您需要的数据!!" &nbsp;<BR>&nbsp;Else &nbsp;<BR>&nbsp; &nbsp;Do 
            &nbsp;While &nbsp;Not &nbsp;Rs.EOF &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp;Response.write &nbsp;Rs("姓名") &nbsp;<BR>&nbsp; 
            &nbsp;Rs.MoveNext &nbsp;<BR>&nbsp; &nbsp;Loop &nbsp;<BR>&nbsp;End 
            &nbsp;IF &nbsp;<BR>&nbsp;Rs.Close &nbsp;<BR>&nbsp;Set 
            &nbsp;Rs=nothing &nbsp;<BR>&nbsp;Conn.Close &nbsp;<BR>&nbsp;Set 
            &nbsp;Conn=Nothing &nbsp;<BR>&nbsp;'Response.Write &nbsp; 
            &nbsp;"成功!" &nbsp;<BR>%&gt; 
            &nbsp;<BR>--------------------------------------------------------------- 
            &nbsp;<BR>&nbsp;<BR>其实跟链数据库差不多的<BR></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 + -