asp读取excel表名的实现代码
程序员文章站
2022-07-01 23:10:56
看代码: 复制代码 代码如下: <%@language="vbscript" codepage="65001"%> <% dim conn,rs,exce...
看代码:
<%@language="vbscript" codepage="65001"%>
<%
dim conn,rs,excelfilename
excelfilename=server.mappath("data/test.xls")
set conn = server.createobject("adodb.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0;persist security info=true;data source=" & excelfilename & ";extended properties=""excel 8.0;hdr=yes;imex=1"";"
conn.open()
set rs=conn.openschema(20)
%>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>excel操作</title>
</head>
<body>
<%
dim i
response.write("excel表信息字段:<br />------------------------<br />")
for i=0 to rs.fields.count-1 step 1
response.write(rs.fields(i).name&"<br />")
next
response.write("<br />excel中的表名(table_name):<br />------------------------<br />")
while not rs.eof
response.write(rs("table_name")&"<br />")
rs.movenext
wend
%>
</body>
</html>
复制代码 代码如下:
<%@language="vbscript" codepage="65001"%>
<%
dim conn,rs,excelfilename
excelfilename=server.mappath("data/test.xls")
set conn = server.createobject("adodb.connection")
conn.connectionstring="provider=microsoft.jet.oledb.4.0;persist security info=true;data source=" & excelfilename & ";extended properties=""excel 8.0;hdr=yes;imex=1"";"
conn.open()
set rs=conn.openschema(20)
%>
<!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>excel操作</title>
</head>
<body>
<%
dim i
response.write("excel表信息字段:<br />------------------------<br />")
for i=0 to rs.fields.count-1 step 1
response.write(rs.fields(i).name&"<br />")
next
response.write("<br />excel中的表名(table_name):<br />------------------------<br />")
while not rs.eof
response.write(rs("table_name")&"<br />")
rs.movenext
wend
%>
</body>
</html>