public DataSet ExecleDs(string filenameurl, string table, string excelTableName)
{
excelTableName = string.IsNullOrWhiteSpace(excelTableName) ? "Sheet1" : excelTableName;
string strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" + "data source=" + filenameurl + ";Extended Properties='Excel 8.0; HDR=yes; IMEX=1'";
string strcom = "select *from [" + excelTableName + "$]";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter odda = new OleDbDataAdapter(strcom, conn);
odda.Fill(ds, table);
conn.Close();
return ds;
}
{
excelTableName = string.IsNullOrWhiteSpace(excelTableName) ? "Sheet1" : excelTableName;
string strConn = "Provider = Microsoft.Jet.OLEDB.4.0;" + "data source=" + filenameurl + ";Extended Properties='Excel 8.0; HDR=yes; IMEX=1'";
string strcom = "select *from [" + excelTableName + "$]";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter odda = new OleDbDataAdapter(strcom, conn);
odda.Fill(ds, table);
conn.Close();
return ds;
}