Excel 2007 , OleDB Select command: [Table1] access in stead of [Sheet1$}
Can we get data from table feature of Excel 2007 / 2010?
Ex.
Select * from Table1 or Table 6,
instead of select * from [Sheet1$]
1 answer
An example for Excel 2007
You should create in your own Excel File in:
Formulas -> Name manager (I don't know exactly that name in english), selecting your table, and bind a name for that, for example, myTable.
In your application, you select again the sheet:
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [sheet$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
But here you can select a table:
objAdapter1.Fill(objDataset1, "myTable");