Microsoft.ACE.OLEDB.12.0 Get worksheet name

I was looking for a way to get the first worksheet name in a spreadsheet that I downloaded.

Now I have found many options or code when it comes to using Jet 4, but I have to use Ace 12, and when I use this driver it will never get anything about the spreadsheet. Does anyone know a good way to pull out a table name with Ace 12?

+4
source share
1 answer

Since the entire worksheet is listed as table names, you can use the OleDbConnection.GetOleDbSchemaTable () method to get a list of all the sheets in a file. I am not sure about the order in which they are returned, but I would expect them to be in order of work.

DataTable dt = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null); string workSheetName = (string)dt.Rows[0]["TABLE_NAME"]; 
+12
source

All Articles