hi
i have a excel file named as myexcel.xsls file and there are 10 sheets in that excel file named as summary,detail,kpi,orders etc etc.In excel sheet summary there are 5 tables in it named as Table1,Table2,Table3,Table4,Table5.Tables are created like I want to get Table1 records into the Data Table so for that i've written a following code
public DataTable GetExcelFileAsDataTable(string FileName)
{
DataTable dt = new DataTable();
OleDbConnection objConn = null;
try
{
objConn = new OleDbConnection(GetConnectionString(FileName));
OleDbCommand objCmd = new OleDbCommand("Select * From [Summary$]", objConn);
SPSecurity.RunWithElevatedPrivileges(delegate()
{
objConn.Open();
});
OleDbDataReader dr = objCmd.ExecuteReader();
if (dr != null)
{
dt.Load(dr);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
objConn.Close();
}
return dt;
}
But when i run that code it returns all the data from the summary sheet means all the rows from that summary sheet.
Can anyone tell me how i can only get single table which is Table1 or all the tables in the data set with each table with it's name