主意利用asc码
/*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 */ public class ExcelSheetColumnNumber1 { public static void main(String[] args) { System.out.println(titleToNumber("AB")); } public static int titleToNumber(String s) { int sum=0; char[] ch=s.toCharArray(); for(int i=s.length()-1;i>=0;i--) sum+=(ch[i]-64)*Math.pow(26,(s.length()-i-1) ); return sum; } }