How do I get all Sheet names from Excel

Posted on 2006-06-28
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
  • 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity dynamic formulas in runtime 11 74
Set value of dynamically created checkboxlist 2 31
Disable extension 8 36
VB.Net - MemoryMappedFiles - Confirm receipt 2 17
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: (…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now