web 2.0

How to use ASP & Read Excel file (Excel.Application)

How to use ASP & Read Excel file (Excel.Application) This is learn/tutorial asp developers how to using ASP script and Read excel file.

ShotDev Focus:
- ASP & Read excel file.

ASP & Read excel file.

Example

asp_read_excel.asp


<%Option Explicit%>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Dim xlApp,xlBook,xlSheet1,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)
%>
<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>
<%
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_excel.asp

Screenshot

ASP & Read excel file.
.
.
.
Download this script.
Download

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

Leave a Reply

You must be logged in to post a comment.