public static void main(String[] args) { // 列索引从0开始 int columnIndex = 730; String back = ""; if (columnIndex <= 0) { back = ""; } String columnStr = ""; do { /* 索引从0开始,如果不减1,从倒数第二位向前都会递加一位 如730,减一是ABC,不减是BCC */ if (columnStr.length() > 0) { columnIndex--; } columnStr = ((char) (columnIndex % 26 + (int) 'A')) + columnStr; columnIndex = (int) ((columnIndex - columnIndex % 26) / 26); } while (columnIndex > 0); back = columnStr; System.out.println(back); }
转载于:https://my.oschina.net/kevin2kelly/blog/908703