How about using
Math.DivRem(...)
?
E.g.
public static string ToExcelName(int num)
{
List<char> digits = new List<char>();
do
{
int rem;
num = Math.DivRem(num, 26, out rem);
digits.Add(Convert.ToChar(65+rem));
} while (num != 0);
return string.Join(null, digits.Reverse<char>());
}
Cheers
Andi