i have one code and i have to find the table from which the data have been retrieved here is the code
- private static DataSet ImportExcelXLS(string FileName, bool hasHeaders)
- {
- string HDR = hasHeaders ? "Yes" : "No";
- string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileName + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=1\"";
-
- DataSet output = new DataSet();
-
- using (OleDbConnection conn = new OleDbConnection(strConn))
- {
- conn.Open();
-
- DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
-
- foreach (DataRow row in dt.Rows)
- {
- string sheet = row["TABLE_NAME"].ToString();
-
- OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);
- cmd.CommandType = CommandType.Text;
-
- DataTable outputTable = new DataTable(sheet);
- output.Tables.Add(outputTable);
- new OleDbDataAdapter(cmd).Fill(outputTable);
- }
- }
- return output;
- }