get excel sheets from c#
-
I would like to know how to get the name of the excel sheets in a excel file using odbc driver? i do not want to open a excel object, since i have to process many files and the only information I need is the sheet name. thank you drey
Try opening it using the Jet 40 provider for Oledb (System.data.oledb classes), use Extended properties = Excel 8.0 in the connection string, Data source is directory, initial catalog is file name. then try : public DataTable GetTables(OleDbConnection conn) { conn.Open(); DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"}); conn.Close(); return schemaTable; } Absolute faith corrupts as absolutely as absolute power Eric Hoffer The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not. Eric Hoffer
-
Try opening it using the Jet 40 provider for Oledb (System.data.oledb classes), use Extended properties = Excel 8.0 in the connection string, Data source is directory, initial catalog is file name. then try : public DataTable GetTables(OleDbConnection conn) { conn.Open(); DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"}); conn.Close(); return schemaTable; } Absolute faith corrupts as absolutely as absolute power Eric Hoffer The opposite of the religious fanatic is not the fanatical atheist but the gentle cynic who cares not whether there is a god or not. Eric Hoffer
thank you, that would be perfect IF i could use the microsoft.jet.4.0 driver. But, so far I keep getting the message saying the that the porvider is not registered on the local machine. Even thought, it is : I download the:sigh: lastest, i check the registry and i manually register using the regsvr32 sqloledb.dll. but nothing worked. so, i decided to try the odbc and it works, but i do not know how to get the tables with it. I appreciate any suggestions...