<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP Excel.Application Tutorial</title>
</head>
<body>
<%
Dim xlApp,xlBook,xlSheet1,xlSheet2,OpenFile,i
OpenFile = "MyXls/MyExcelDB.xls"
'*** Create Exce.Application ***'
Set xlApp = Server.CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(Server.MapPath(OpenFile))
Set xlSheet1 = xlBook.Worksheets(1)
%>
Sheet 1
<table width="420" border="1">
<%For i = 1 To 5%>
<tr>
<td><%=xlSheet1.Cells.Item(i,1)%></td>
<td><%=xlSheet1.Cells.Item(i,2)%></td>
<td><%=xlSheet1.Cells.Item(i,3)%></td>
<td><%=xlSheet1.Cells.Item(i,4)%></td>
</tr>
<%Next%>
</table>
<%
Set xlSheet2 = xlBook.Worksheets(2)
%>
Sheet 2
<table width="420" border="1">
<%For i = 1 To 5%>
<tr>
<td><%=xlSheet2.Cells.Item(i,1)%></td>
<td><%=xlSheet2.Cells.Item(i,2)%></td>
<td><%=xlSheet2.Cells.Item(i,3)%></td>
<td><%=xlSheet2.Cells.Item(i,4)%></td>
</tr>
<%Next%>
</table>
<%
xlApp.Application.Quit
'*** Quit and Clear Object ***'
Set xlSheet1 = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
%>
</body>
</html>