title: Reading data from excel sheet in c#, loading data into a strings for each column in a row
body: <p>I am working on reading data from excel sheet. My table will look like this. </p>
  
  <pre><code>        AAAA            bbbbb              cccc
          1                2                  3
          4                5                  6
          --------------------------------------
  
  
  
          --------------------------------------
  
         data           data                  data
  </code></pre>
  
  <p>I want to loop though each and every row and save each value at each cell in a seperate string.</p>
  
  <p>Here as per my table,</p>
  
  <p>I want to store,</p>
  
  <pre><code>    string column1= 1;
      string cloumn2=2;
      string clomnn3= 3;
  </code></pre>
  
  <p>I want to repeat this for all rows. My excel will have only three columns.</p>
  
  <p>I have tried this code</p>
  
  <pre><code>        //Reading Excel file
          string datafilename = @"D:\Book2.xls";
          string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + datafilename + ";" + "Extended Properties=Excel 12.0;"; 
          OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
          //fetching excel data into DataTable 
          System.Data.DataTable _dtDataFile = new System.Data.DataTable();
          ArrayList abcd = new ArrayList();
          myCommand.Fill(_dtDataFile);
  
          foreach (DataRow row in _dtDataFile.Rows)
          {
              Response.Write(row[i]);
  
          } 
  </code></pre>
  
  <p>The output i got is </p>
  
  <pre><code>    12346............datadatadata
  </code></pre>
  
  <p>I am getting all data in a single string, i want to store data in seperate strings for each row.</p>
  
  <p>Can any one suggest, how to do this.</p>
  
  <p>Thank you.</p>