How do I get all Sheet names from Excel

Posted on 2006-06-28
Medium Priority
Last Modified: 2012-05-05

I am trying to make my VB.NET app look at an Excel sheet and list all of its Worksheet names in a combobox. Can someone show me and example of how I can do this?

Question by:kiranboi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 19

Expert Comment

ID: 16999698
       Dim XL As New Excel.Application
        Dim XLWB As Excel.Workbook
        XLWB = XL.Workbooks.Open("C:\test.xls")
        Dim Sh As Excel.Worksheet
        For Each Sh In XLWB.Sheets
LVL 19

Expert Comment

ID: 16999709
And don't forget to quit the App after everything is done...


Author Comment

ID: 16999726
Is there anyway of doing it through OleDb so I dont have to import Excel?
LVL 19

Accepted Solution

arif_eqbal earned 2000 total points
ID: 16999805

        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\YOUR_PATH\YOUR_XL_FILE.xls;Extended Properties=""Excel 8.0;HDR=YES;"""
        Dim Cn As New OleDbConnection(ConStr)
        Dim DT As DataTable = Cn.GetSchema("Tables")
        For Each dr As DataRow In DT.Rows

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question