In enterprise-class applications, we often need to operate on execl, such as reading execl inside the data, inserting data into the execl. First, the operation of the EXECL to note: 1, the configuration of server-side office in the case of Ms Windows2000+iis, there are no special requirements for a version of Execl,office installed on the server side of MS Office. 2. Server-side Distributed COM configuration execute the "DCOMCNFG" command, select the Microsoft execl application-> Properties-> "Security"-> the Applications page, and choose "Use custom access rights" to add ' Everyone ' permission. Second, first of all, will take advantage of ASP to read EXECL data (do not create DSN): We can view the entire. xsl file as a database, Sheet1, Sheet2, etc., respectively, as a separate table, the A1, B1, C1 、... N1 as a table field. --Establish a Connection object instance Execlconn set Execlconn=server.createobject ("ADODB. Connection ")--open the database using the Open method strconn=" Driver={microsoft Excel Driver (*.xls)}; " &_ "driverid=790; Dbq= "& Server.MapPath (" XLS filename ") conn. Open strconn--Establishes the DataSet object RS and queries the data Set rs = Server.CreateObject ("ADODB. Recordset ") sql=" select * from [sheet1$] "Rs. Open sql,conn,2,2 Concrete Example: 1, establish a table Sheet1 (database name is students)
StudentID |
Name |
Language |
Mathematical |
Physical |
Chemical |
Geographical |
|
1 |
Li Xieqing |
83 |
84 |
76 |
95 |
66 |
|
2 |
Feng Jiang |
87 |
96 |
82 |
100 |
81 |
|
3 |
Wu Xiaoxia |
76 |
43 |
37 |
60 |
82 |
|
4 |
Shian Hui |
80 |
77 |
63 |
71 |
63 |
|
5 |
Cai Haifei |
89 |
63 |
92 |
86 |
67 |
|
2, query and display the contents of the table Sheet1 code <% Dim conn Dim strconn Dim rs Dim Sql Set conn=server.createobject ("ADODB. Connection ") strconn=" Driver={microsoft Excel Driver (*.xls)}; " &_ "driverid=790; Dbq= "& Server.MapPath (" Students.xls ") Conn. Open strconn Set rs = Server.CreateObject ("ADODB. Recordset ") sql=" select * from [sheet1$] "Rs. Open sql,conn,2,2%> <center> <table border= "1" > <tr> <% for i=0 to Rs. Fields.count-1%> <td bgcolor= "#0099FF" ><%=rs (i). Name%></td> <% Next%> </tr> <% do, not Rs. EOF%> <tr> <% for i=0 to Rs. Fields.count-1%> <td><%=rs (i)%></td> <% next%> </tr> <% Rs. MoveNext Loop rs.close set rs=nothing strconn.close set strconn=nothing%> </table></center>