I am trying to get data from an excel sheet and it throws me that error
The Microsoft Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly. If 'Sheet1$' is not a local object, check your network connection or contact the server administrator.
here is my code
string filename = System.IO.Path.GetFullPath(Server.MapPath("~/App_Data/country_code.xlsx")); OleDbConnection countryConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + "; Extended Properties=Excel 12.0 Xml;"); try { OleDbCommand com = new OleDbCommand("select * from [Sheet1$]", countryConnection); countryConnection.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = com; DataSet ds = new DataSet(); adapter.Fill(ds); } catch(Exception ex) { ViewBag.Error = ex.Message; }
the path to the file is right
i created anther project to test the same code and it worked fine, both are on my local machine