How to use ASP & Read Multiple worksheet from excel (Excel.Application) This is learn/tutorial asp developers how to using ASP script and Read Multiple worksheet from excel (Excel.Application)
ShotDev Focus:
- ASP & Read Multiple worksheet from excel (Excel.Application)
Example
asp_read_multiple.asp
<%Option Explicit%>
<html>
<head>
<title>ShotDev.Com 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">
<%
i = 1
While xlSheet1.Cells.Item(i,1) <> ""
%>
<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>
<td><%=xlSheet1.Cells.Item(i,5)%></td>
<td><%=xlSheet1.Cells.Item(i,6)%></td>
</tr>
<%
i = i + 1
Wend
%>
</table>
<%
Set xlSheet2 = xlBook.Worksheets(2)
%>
Sheet 2
<table width="420" border="1">
<%
i = 1
While xlSheet2.Cells.Item(i,1) <> ""
%>
<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>
<td><%=xlSheet2.Cells.Item(i,5)%></td>
<td><%=xlSheet2.Cells.Item(i,6)%></td>
</tr>
<%
i = i + 1
Wend
%>
</table>
<%
xlApp.Application.Quit
'*** Quit and Clear Object ***'
Set xlSheet1 = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
%>
</body>
</html>
Create a asp file and save to path root-path/myasp/
Run
http://localhost/myasp/asp_read_multiple.asp
Screenshot



1granted…
…