Excel Sheet Column Number
Related to question Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28
- static public int TitleToNumber(string s) {
int number = 0;
int deliver = 1;
char[] chars = s.ToCharArray();
int length = chars.Length;
for (int i = length-1; i>=0; i--) {
number += (chars[i] - 65 + 1) * deliver;
deliver *= 26;
}
return number;
}