asp读取excel文件

时间:2009-05-19    点击:1631   

asp读取excel文件,关键语句是数据库连接方式.

<table border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
   <td>用户名</td>
   <td>密码</td>
  </tr>
<%

strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.MapPath("test.xls")&";Extended Properties=Excel 8.0;"
Set cnexcel = Server.CreateObject("ADODB.Connection")
cnexcel.Open StrConn


sql="select * from [Sheet1$]"  '表名称$
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,cnexcel,1,3

if rs.eof and rs.bof then

else
  i=0
  do while not rs.eof

    i=i+1 
%>


<tr bgcolor="#FFFFFF">
  <td><%=rs("用户名")%></td>
  <td><%=rs("密码")%></td>
</tr>

<% 
 
  rs.movenext
  loop
end if
Rs.Close
Set Rs=nothing

%>

</table>

下载

asp.net随机读取access数据库
GridView显示主细表并一次编辑明细表所有数据
多组单选框是否选中
javascript音乐歌词同步
导航特效
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 All Rights Reserved