Excel worksheets' names

vasolis

New member
Joined
Aug 16, 2006
Messages
2
Programming Experience
5-10
Hello all.

I have trouble listing all worksheet's names from an excel file.
I know that by using an OleDbConnection you can connect to an excel file and with a command like this:
select * from [sheet1$]
you can retrieve all data from sheet1, since sheet1 is considered as a table.

The problem is when I have multiple sheets how can I find all sheets' names?
For example if I want to Load an .xls file, I want a combo box to display all the sheets in order to choose from where to retrieve the data from.

Thanx in advance
 
The GetSchema method of the OleDbConnection class returns a DataTable that contains schema information about the collection of objects that you specify.
VB.NET:
myComboBox.DisplayMember = "TABLE_NAME"
myComboBox.DataSource = myOleDbConnection.GetSchema("Tables")
 
Back
Top