Try the following where the extension method ExcelColumnName is for getting into double characters for column names as there are in Excel.
Mockup
public static class ExtensionMethods
{
public static string ExcelColumnName(this int index)
{
var chars = new char[]
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
};
index -= 1;
string columnName;
var quotient = index / 26;
if (quotient > 0)
{
columnName = ExcelColumnName(quotient) + chars[index % 26];
}
else
{
columnName = chars[index % 26].ToString();
}
return columnName;
}
}
Form code
for (int index = 1; index < 100; index++)
{
var value = index.ExcelColumnName();
if (value.Length == 1)
{
Debug.WriteLine(value);
}
else
{
Debug.WriteLine($"\t{value}");
foreach (var character in value)
{
Debug.WriteLine($"\t\t{char.Parse(character.ToString())}");
}
}
}
Partial output
X
Y
Z
AA
A
A
AB
A
B
AC
A
C
AD
A
D
AE
A
E
AF
A
F