01.
<%
Option
Explicit %>
02.
<html>
03.
<head>
04.
<title>ThaiCreate.Com ASP Excel.Application Tutorial</title>
05.
</head>
06.
<body>
07.
<%
08.
Dim
xlApp,xlBook,xlSheet1,OpenFile,i
09.
OpenFile =
"MyXls/MyExcelDB.xls"
10.
11.
Set
xlApp = Server.CreateObject(
"Excel.Application"
)
12.
Set
xlBook = xlApp.Workbooks.Open(Server.MapPath(OpenFile))
13.
14.
Set
xlSheet1 = xlBook.Worksheets(1)
15.
%>
16.
<table width=
"420"
border=
"1"
>
17.
<%
For
i = 1
To
5%>
18.
<tr>
19.
<td><%=xlSheet1.Cells.Item(i,1)%></td>
20.
<td><%=xlSheet1.Cells.Item(i,2)%></td>
21.
<td><%=xlSheet1.Cells.Item(i,3)%></td>
22.
<td><%=xlSheet1.Cells.Item(i,4)%></td>
23.
</tr>
24.
<%
Next
%>
25.
</table>
26.
<%
27.
xlApp.Application.Quit
28.
29.
30.
Set
xlSheet1 =
Nothing
31.
Set
xlBook =
Nothing
32.
Set
xlApp =
Nothing
33.
%>
34.
</body>
35.
</html>