当前位置: 代码迷 >> ASP >> asp 读取excel例证
  详细解决方案

asp 读取excel例证

热度:154   发布时间:2012-10-26 10:30:59.0
asp 读取excel例子

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="
http://www.w3.org/1999/xhtml " lang="gb2312" xml:lang="gb2312">
<head>
???
<title>操作excle</title>
</head>

<body>
<%
Set xlsconn = server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")

myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.xls;Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl

sql="select * from [sheet1$]"
set rs=xlsconn.execute(sql)
if not rs.eof then
%>
<table border="0" cellpadding="20" cellspacing="0" >
<tr>
<td>名称</td>
<td>编号</td>
<td>价格</td>
</tr>
<%
while not rs.eof
%>
<tr>
<td><%=rs("商品名称")%></td>
<td><%=rs("商品编号")%></td>
<td><%=rs("价格")%></td>
</tr>
<%
rs.movenext
wend
%>
</table>

<%
'sql="insert into [product](namese,pic) values('"& names &"','"& pic &"')"
'conn.execute(sql)


end if

%>


</body>
</html>

  相关解决方案