r_khan
یک شنبه 25 تیر 1391, 23:46 عصر
سلام
برای ریختن excel در table و گریدویو از کد زیر استفاده کردم ولی خطا میده کد و خطا را میزارم
string connString = @"Provider = Microsoft.Jet.OLEDB.4.0;Data Source=Book1.xls;Extended Properties=Excel 8.0";
OleDbConnection oledbConn = newOleDbConnection(connString);
try
{
oledbConn.Open();
OleDbCommand cmd = newOleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
OleDbDataAdapter oleda = newOleDbDataAdapter();
oleda.SelectCommand = cmd;
DataSet ds = newDataSet();
oleda.Fill(ds, "Customer");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
catch
{
}
finally
{
oledbConn.Close();
}
اینم خطا
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
برای ریختن excel در table و گریدویو از کد زیر استفاده کردم ولی خطا میده کد و خطا را میزارم
string connString = @"Provider = Microsoft.Jet.OLEDB.4.0;Data Source=Book1.xls;Extended Properties=Excel 8.0";
OleDbConnection oledbConn = newOleDbConnection(connString);
try
{
oledbConn.Open();
OleDbCommand cmd = newOleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
OleDbDataAdapter oleda = newOleDbDataAdapter();
oleda.SelectCommand = cmd;
DataSet ds = newDataSet();
oleda.Fill(ds, "Customer");
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
catch
{
}
finally
{
oledbConn.Close();
}
اینم خطا
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.