title: how to read data column headers and data of each cell in Excel Using c#
body: <p>I have an excel sheet similar to :</p>
  
  <p><img src="https://i.stack.imgur.com/GOI1F.png" alt="excel screenshot"></p>
  
  <p>I want to read data columns header:All,col1,col2,col3,col4,col5</p>
  
  <p>and get all cell data.for example cell in Row = 2 and column 2 = 0</p>
  
  <p>I currently write this code :</p>
  
  <pre><code>OleDbDataAdapter dbAdapter = new OleDbDataAdapter("SELECT top 5 * FROM " + excelSheets[j], connString);
  DataTable fooData = new DataTable();
  dbAdapter.Fill(fooData);
  foreach (DataRow row in fooData.Rows)
  {
      Response.Write(row[0].ToString());
      //Response.Write(row[1].ToString());
  }
  </code></pre>
  
  <p>but it return just a data table with 1 column and just row 1..5 text.</p>
  
  <p>How I can do this?</p>
  
  <p>Please say answer without using Linq to Excel Provider and Open Xml.</p>
  
  <p>Edit 1:</p>
  
  <pre><code>string file_name = "C:\\Book1.xlsx";
          string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file_name + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
          objConn = new OleDbConnection(connString);
          objConn.Open();
          dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
  
          if (dt == null)
          {
              Response.Write("Not Exist");
          }
  
          String[] excelSheets = new String[dt.Rows.Count];
          int i = 0;
  
          foreach (DataRow row in dt.Rows)
          {
              excelSheets[i] = row["TABLE_NAME"].ToString();
              i++;
          }
  
          // Loop through all of the sheets if you want too...
          for (int j = 0; j &lt; excelSheets.Length; j++)
          {
              OleDbDataAdapter dbAdapter = new OleDbDataAdapter("SELECT top 100 * FROM " + excelSheets[j], connString);
              DataTable fooData = new DataTable();
              dbAdapter.Fill(fooData);
              foreach (DataRow row in fooData.Rows)
              {
                  Response.Write(row[0].ToString());
              }
  
          }
  </code></pre>