title: How to get column index in Excel using excel-column-name format in C#
body: <p>I have found here
  <a href="http://lateral8.com/articles/2010/3/5/openxml-sdk-20-export-a-datatable-to-excel.aspx" rel="nofollow noreferrer">http://lateral8.com/articles/2010/3/5/openxml-sdk-20-export-a-datatable-to-excel.aspx</a>
  a great function</p>
  
  <pre><code>private string getColumnName(int columnIndex)
  {
      int dividend = columnIndex;
      string columnName = String.Empty;
      int modifier;
  
      while (dividend &gt; 0)
      {
          modifier = (dividend - 1) % 26;
          columnName = 
              Convert.ToChar(65 + modifier).ToString() + columnName;
          dividend = (int)((dividend - modifier) / 26);
      }
  
      return columnName;
  }
  </code></pre>
  
  <p>I would like to do similar thing - provide column name and receive index. For example provide name 'AB' and receive as result index 28. How to do this?</p>
  
  <p>UPDATE:</p>
  
  <p>Surprising, I have found solution in the comments section</p>
  
  <p>here
  <a href="https://stackoverflow.com/a/8739121/907732">https://stackoverflow.com/a/8739121/907732</a></p>
  
  <p>and here
  <a href="https://stackoverflow.com/a/4888750/907732">https://stackoverflow.com/a/4888750/907732</a></p>