static int excelNum(String header){
int sum = 0;
if(header != null){
int len = header.length();
for(int i=0; i<len; i++){
int n = header.charAt(len-1 - i) - 'A' + 1;
sum += n*Math.pow(26, i);
}
}
return sum;
}
// 0 -> 'A'
// 1 -> 'B'
// 25 -> 'Z'
// num = 1 -> 'A'
// num = 26 -> 'A' + 25 = 'Z'
// num = 27
// reminder = 0 -> 'A'
// num = 1
// reminder = 0 -> 'A'
// num = 52
// (52 - 1) % 26 = 25 -> 'Z'
// 52 / 26 = 2
// x = ['A' - 'Z'] - 'A'
// x = [0 ... 25]
//
// n = x + 1
// sum = (x + 1)*pow(26, 2) + (x + 1)*pow(26, 1) + (x+1)*pow(26, 0)
static String numToHeader(int num){
String str = "";
while(num > 0){
int reminder = (num - 1) % 26;
char ch = (char)(reminder + 'A');
str = ch + "" + str;
num = (num - 1) / 26;
}
return str;
}