/**
* 列转数字下标
* @param col AAA
* @return
*/
public static int excelToNum(String col) { // "AAA"
if (col == null) {
return -1;
}
char[] chrs = col.toUpperCase().toCharArray(); // 转为大写字母组成的 char数组
int length = chrs.length;
int index = -1;
for (int i = 0; i < length; i++) {
index += (chrs[i] - 'A' + 1) * Math.pow(26, length - i - 1); // 当做26进制来算 AAA=111 26^2+26^1+26^0
}
return index ;// 从0开始的下标
}
05-01
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交