title: C# iterate over a row in Excel
body: <p>I need to iterate over a specific excel row. For now I've got a code to iterate over a column and I want it to be similar to that. It looks like this:</p>
  
  <pre><code>int columnLength = xlWorkSheet.UsedRange.Rows.Count;
  string lastCell = Regex.Replace(CONST_FIRST_CELL, @"\d+", columnLength.ToString()); //will give me the last cell in the column
  var excelColumn = xlWorkSheet.Range[CONST_FIRST_CELL, lastCell ];
      if (excelColumn == null)
      {
        throw new Exception("bad col");
      }
      for (int i = 1; i &lt; columnLength ; i++)
      {
        Excel.Range currentValue = excelColumn [i];
        ....DO SOME STUFF....
      }
  </code></pre>
  
  <p>how can I iterate over a specific row? I'm not sure how to get the last column like I got the last row cell in the above implementation since then I just had to switch a number with the length but now I somehow need to get the correct last cell of a row (which means switching the letters somehow i.e C4 to AD4) in order to get the range of first cell row and last...</p>
  
  <p>The best solution I guess involves a foreach loop somehow?</p>