web 2.0

How to use ASP & Connect Excel Using ADO (DRIVER={Microsoft Excel Driver (*.xls)})

How to use ASP & Connect Excel Using ADO (DRIVER={Microsoft Excel Driver (*.xls)}) This is learn/tutorial asp developers how to using ASP script Connect Excel ADO Driver.

ShotDev Focus:
- ASP & Connect Excel ADO Driver.

ASP & Connect Excel ADO Driver.

Example

asp_excel_ado.asp


<%Option Explicit%>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Dim OpenFile,i
Dim Conn,objRec,strSQL

OpenFile = "MyXls/MyExcelDB.xls"
Set Conn = Server.CreateObject("ADODB.Connection")

'*** Connect to Excel ***'
Conn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; "&_
"Excel 8.0; DBQ=" & Server.MapPath(OpenFile) & "; "

'*** Select Sheet ***'
strSQL = "SELECT * FROM [Sheet1$]"
Set objRec = Conn.Execute(strSQL)
%>
<table width="420" border="1">
<tr>
<td>CustomerID</td>
<td>Name</td>
<td>Email</td>
<td>CountryCode</td>
<td>Budget</td>
<td>Used</td>
</tr>
<%
While Not objRec.EOF
%>
<tr>
<td><%=objRec.Fields("CustomerID").Value%></td> <!-- objRec.Fields(0).Value or objRec.Fields("CustomerID").Value -->
<td><%=objRec.Fields("Name").Value%></td>
<td><%=objRec.Fields("Email").Value%></td>
<td><%=objRec.Fields("CountryCode").Value%></td>
<td><%=objRec.Fields("Budget").Value%></td>
<td><%=objRec.Fields("Used").Value%></td>
</tr>
<%
objRec.MoveNext
Wend
%>
</table>
<%
objRec.Close
Conn.Close
Set objRec=Nothing
Set Conn=Nothing
%>
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_excel_ado.asp

Screenshot

ASP & Connect Excel ADO Driver.
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

One Response to “How to use ASP & Connect Excel Using ADO (DRIVER={Microsoft Excel Driver (*.xls)})”

  1. 3callous…

Leave a Reply

You must be logged in to post a comment.