Home  >  Article  >  Backend Development  >  asp reads the value of row x and column y of excel table

asp reads the value of row x and column y of excel table

PHP中文网
PHP中文网Original
2017-08-19 13:21:302191browse

This article introduces how asp reads data in excel tables. Excel2007 supports sql query to read data. Excel can be regarded as a database.

The following code has been tested by me and is available for your reference.

The code is as follows:

<%
&#39;读取x行y列
set Conn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("1.xls")+";Extended Properties=&#39;Excel 8.0;HDR=no;IMEX=1&#39;"
Conn.Open strConn
function getxy(table,x,y)
sql="SELECT * FROM ["&table&"$]"
rs.Open sql,Conn,1,1
if not rs.eof then 
rs.move x-1 
getxy=rs(y-1)
else
getxy=""
end if
rs.Close
Conn.Close
set rs = Nothing
set Conn = Nothing
end function
response.write getxy("民政婚姻登记",3,4)
%>

I am provided by PHP Chinese website. I am "Ty80", the author of PHP Chinese website.

Article address: http://www.php.cn/csharp-article-377119.html

Come to PHP Chinese website to learn programming www.php.cn

The above is the detailed content of asp reads the value of row x and column y of excel table. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn