title: Accessing Excel 2013 File in ASP.NET
body: <p>I am developing an ASP.NET application. I have an Excel 2013 file named ExcelApp and i have also added in my project. I can not access the file.</p>
  
  <p>Here is my DAL class:</p>
  
  <pre><code>public string ExcelConnection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Nimit\ExcelApplication.xlsx;Extended Properties='Excel 12.0 Xml';HDR=YES"; 
      OleDbDataAdapter DbAdap;
      DataTable dt;
  
      public DataTable Get_ExcelSheet()
      {
          OleDbConnection DbCon = new OleDbConnection(ExcelConnection);
  
          DbAdap = new OleDbDataAdapter("SELECT * FROM [Sheet1$]",DbCon);
          dt = new DataTable();
          DbAdap.Fill(dt);
          return dt;
      }
  </code></pre>
  
  <p>My cs file code: </p>
  
  <pre><code>public partial class WebForm1 : System.Web.UI.Page
  {
      DAL obj = new DAL();
      protected void Page_Load(object sender, EventArgs e)
      {
          if (!IsPostBack == true)
          {
              Get_Data();
          }
      }
  
      void Get_Data()
      {
          GridView1.DataSource = obj.Get_ExcelSheet();
          GridView1.DataBind();
      }
  }
  </code></pre>
  
  <p>My debugger shows the error while executing this line:</p>
  
  <pre><code>DbAdap.Fill(dt);
  </code></pre>
  
  <p>The exception is: </p>
  
  <p><img src="https://i.stack.imgur.com/hjwpi.jpg" alt="enter image description here"></p>