Answers for "c# convert column name to number"

C#
0

c# convert column name to number

public static int ExcelColumnNameToNumber(string columnName)
{
    if (string.IsNullOrEmpty(columnName)) throw new ArgumentNullException("columnName");

    columnName = columnName.ToUpperInvariant();

    int sum = 0;

    for (int i = 0; i < columnName.Length; i++)
    {
        sum *= 26;
        sum += (columnName[i] - 'A' + 1);
    }

    return sum;
}
Posted by: Guest on March-09-2020

Code answers related to "c# convert column name to number"

C# Answers by Framework

Browse Popular Code Answers by Language