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;
- }


Salman BegRank #284 · 8.8K reputationPosted Feb 26, 2019, 7:43 PM EST
Madan ShekarRank #428 · 5.9K reputationPosted Feb 26, 2019, 7:44 PM EST
Madan ShekarRank #428 · 5.9K reputationPosted Feb 26, 2019, 7:45 PM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 26, 2019, 7:58 PM EST
Subin ThomasRank #724 · 3.2K reputationPosted Feb 26, 2019, 7:52 PM EST
Subin ThomasRank #724 · 3.2K reputationPosted Feb 26, 2019, 7:52 PM EST
Subin ThomasRank #724 · 3.2K reputationPosted Feb 26, 2019, 7:56 PM EST
Subin ThomasRank #724 · 3.2K reputationPosted Feb 26, 2019, 8:00 PM EST
Salman BegRank #284 · 8.8K reputationPosted Feb 26, 2019, 8:10 PM EST