title: How to load gridview from a excel file in asp.net by c#?
body: <p>I tried load a gridview from excel file.But I get this error</p>
  
  <p>The Microsoft Jet database engine 'Sheet1 $' could not find the object. Make sure the object exists and that its name is spelled correctly and the path.</p>
  
  <p>And there is an error in this line :    excelDataAdapter.Fill(dt);</p>
  
  <p>I have a .xls file in App_Data folder.Wh</p>
  
  <pre><code> using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.IO;
  using System.Data;
  using System.Data.OleDb;
  
  
  
  
  namespace Excell
  {
  public partial class LoadExcelToGrid: System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
         gv.DataSource = exceldata(Server.MapPath("~/data.xls"));
         gv.DataBind();
      }
      public static DataSet exceldata(string filelocation)
      {
          DataSet ds = new DataSet();
          OleDbCommand excelCommand = new OleDbCommand(); OleDbDataAdapter excelDataAdapter = new 
   OleDbDataAdapter();
          string excelConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + filelocation + 
  "; Extended Properties=Excel 8.0;";
          OleDbConnection excelConn = new OleDbConnection(excelConnStr);
          excelConn.Open();
          DataTable dt = new DataTable();
          excelCommand = new OleDbCommand("Select * from [Sheet1$]", excelConn);
          excelDataAdapter.SelectCommand = excelCommand;
          excelDataAdapter.Fill(dt);
  
          ds.Tables.Add(dt);
  
          return ds;
      }
  
  
  }
  }
  </code></pre>