title: How to fetch data from an excel sheet which contains data in row column format?
body: <p>I have an excel sheet where first row is column names and rest all are rows.</p>
  
  <p>I am reading an excel sheet values by using the following code, but my requirement is to (instead of getting all the values in a sequence) get data as-if indexed by <code>columnname , row</code>. How to get them like this?</p>
  
  <p>Existing code which I am using is:</p>
  
  <pre><code>    Excel.Application xlApp;
      Excel.Workbook xlWorkBook;
      Excel.Worksheet xlWorkSheet;
      Excel.Range range;
      string str;
      int rCnt = 0;
      int cCnt = 0;
      xlApp = new Excel.Application();
      xlWorkBook = xlApp.Workbooks.Open(@"D:\Copy of Macro with Radio_Test.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
      xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
      range = xlWorkSheet.UsedRange;
  
      for (rCnt = 1; rCnt &lt;= range.Rows.Count; rCnt++)
      {
          for (cCnt = 1; cCnt &lt;= range.Columns.Count; cCnt++)
          {
              str = (Convert.ToString((range.Cells[rCnt, cCnt] as Excel.Range).Value2));
              Console.WriteLine(str);
              Console.ReadLine();
          }
      }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>same like <a href="https://stackoverflow.com/questions/29217579/how-to-process-a-well-structured-text-similar-to-excel-sheet-in-c-sharp">How to process a well structured text similar to excel sheet in c#</a>
  but here it is for excel file ,ther it was text files and same logic not working for excel file,mainly i filed to convert range.rows to string arrays and even for columns</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>is it a complicated task, if some body can give me conversion for the following two line is sufficient</p>
  
  <pre><code>string[] rows = range.rows; // here exception for converion
  string[] cols = range.columns;// here also
  </code></pre>
  
  <p>UDPATE</p>
  
  <p>any updates? or we cant do that way??</p>