Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB
static public string ConvertToTitle(int n) {
string s = "";
char c = ‘ ‘;
while (n > 0) {
int num = (n - 1) % 26;
c = Convert.ToChar(num + 65);
s = c + s;
n = (n - 1) / 26;
}
return s;
}
原文:http://www.cnblogs.com/xiejunzhao/p/6271271.html