Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with sheetnames in excel....

Status
Not open for further replies.

Elsje

Programmer
Feb 20, 2004
44
BE
Hello,

I have a problem with retrieving the excel-sheetnames in a file.

I use the following code to get these names and this works fine:
Dim schemaTable As DataTable = conExcel.GetOleDbSchemaTable(Data.OleDb.OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})

But my problem is that I get the names in alphabetical order and I want them in the order of the file.

Thanks in advance...
Elsje
 
Hi
The only way I know how to do it is to use the Excel application and parse through the worksheets:
Code:
dim XL as new Microsoft.Office.Interop.Excel.Application
dim xlWS as Microsoft.Office.Interop.Excel.Worksheet
dim xlWB as Microsoft.Office.Interop.Excel.Workbook
dim strSheet as string

xlWB = XL.Workbooks.Add("C:\myXL.xls")
for each xlWS in xlWB.Worksheets
 strSheet = xlWS.Name
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top