ADOX: how to get true ordinal of Excel Table

  • Thread starter Thread starter Edwin Knoppert
  • Start date Start date
hi,
i am importing excel data through a web form, using ADOX.
i only want to grab the first worksheet, but unfortunately if the user
re-arranges the worksheets in the excel file, the ADOX Catalog.Tables
collection still presents the tables in the original order of the
worksheets.

does anyone know how to identify the ordinal of an excel
worksheet, as it appears to the user when the file is open?

thanks
tim.

if it is of relevance, the c# code i'm using is below:

ADOX.CatalogClass cat = new ADOX.CatalogClass();
ADODB.ConnectionClass connAdox = new ADODB.ConnectionClass();
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\"" + path + "\";Extended Properties=Excel 8.0;";
connAdox.Open(connectionString, "admin","",0);
cat.ActiveConnection = connAdox;
DataSet ds = new DataSet();
OleDbConnection connOleDb = new OleDbConnection (connectionString);
connOleDb.Open();
cat.Tables[0]... etc. etc. // isn't the first worksheet in the file
 
On 22 May 2006 03:16:20 -0700, (e-mail address removed) wrote:

¤ hi,
¤ i am importing excel data through a web form, using ADOX.
¤ i only want to grab the first worksheet, but unfortunately if the user
¤ re-arranges the worksheets in the excel file, the ADOX Catalog.Tables
¤ collection still presents the tables in the original order of the
¤ worksheets.
¤
¤ does anyone know how to identify the ordinal of an excel
¤ worksheet, as it appears to the user when the file is open?
¤
¤ thanks
¤ tim.
¤
¤ if it is of relevance, the c# code i'm using is below:
¤
¤ ADOX.CatalogClass cat = new ADOX.CatalogClass();
¤ ADODB.ConnectionClass connAdox = new ADODB.ConnectionClass();
¤ string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
¤ Source=\"" + path + "\";Extended Properties=Excel 8.0;";
¤ connAdox.Open(connectionString, "admin","",0);
¤ cat.ActiveConnection = connAdox;
¤ DataSet ds = new DataSet();
¤ OleDbConnection connOleDb = new OleDbConnection (connectionString);
¤ connOleDb.Open();
¤ cat.Tables[0]... etc. etc. // isn't the first worksheet in the file

Recently posted a couple of times:

http://tinyurl.com/ze36t


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Back
Top