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.
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