Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Jul 2, 1999



Application Security Testing: An Integral Part of DevOps

Displaying Excel Information in ASP Pages

How can ASP query an Excel sheet and get all the books' names that reside in that Excel document using ADO (or any other way)? I want to display all contents of the Excel sheet on a Web page using ASP.

You will need to use the Excel Object model and write your code to extract the book's sheet names.

To do this, first make sure Excel is installed on your Web Server (or at least registered properly). Then use the following code to extract sheet names from a given Excel file:

   Dim i, objExcel
   Set objExcel = Server.CreateObject("Excel.Application")
    objExcel.Workbooks.Open "filename"
    For i = 1 To objExcel.ActiveWorkbook.Sheets.Count
        Response.Write objExcel.ActiveWorkbook.Sheets(i).Name
    objExcel.ActiveWorkbook.Close False
    Set objExcel = Nothing

You can extend the above code to get whatever else you want from the Excel spreadsheet. If that's what you want you may be better off first having Excel save the spreadsheet as an HTML document and then displaying the document in your application.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date