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:
<% '读取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='Excel 8.0;HDR=no;IMEX=1'" 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: //m.sbmmt.com/csharp-article-377119.html
Come to PHP Chinese website to learn programming m.sbmmt.com
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!