public static void load_xls_to_data_table(string ip_str_path, ref DataTable ip_dt_src)
{
string conStr = "";
conStr = ConfigurationManager.ConnectionStrings["Excel07ConString"].ConnectionString;
conStr = String.Format(conStr, ip_str_path, "Yes");
OleDbConnection con = new OleDbConnection(conStr);
OleDbCommand ExcelCommand = new OleDbCommand();
ExcelCommand.Connection = con;
con.Open();
DataTable ExcelDataSet = new DataTable();
ExcelDataSet = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
DataTable dt = new DataTable();
if(ExcelDataSet != null && ExcelDataSet.Rows.Count > 0)
{
string SheetName = ExcelDataSet.Rows[0]["TABLE_NAME"].ToString(); // get sheetname
ExcelCommand.CommandText = "SELECT * From [" + SheetName + "]";
OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
ExcelAdapter.SelectCommand = ExcelCommand;
ExcelAdapter.Fill(dt);
ip_dt_src = dt;
}
con.Close();
}