public static int ExcelColumnIndex(this string columnName)
{
int number = 0;
int pow = 1;
for (int i = columnName.Length - 1; i >= 0; i--)
{
number += (columnName[i] - 'A' + 1) * pow;
pow *= 26;
}
return number;
}
Example
int bIndex = "B".ExcelColumnIndex();
int amIndex = "AM".ExcelColumnIndex();