js怎么把数字转化为字母(A,B.....AA,AB,..)

海贝数码网   2022年5月30日 浏览量:570

function createCellPos( n ){
var ordA = 'A'.charCodeAt(0);
var ordZ = 'Z'.charCodeAt(0);
var len = ordZ - ordA + 1;
var s = "";
while( n >= 0 ) {

s = String.fromCharCode(n % len + ordA) + s;

n = Math.floor(n / len) - 1;

}
return s;
}

createCellPos(26)//"AA"

原文:https://blog.csdn.net/weixin_42349358/article/details/80517198 

分类:            js


更新日期:2022年5月30日
关键字:js怎么把数字转化为字母(A,B.....AA,AB,..)
免责声明:文章或资料来源于网络,如有关于本文内容、版权或其它问题请于文章发表后的30日内与本网管理员联系删除或修改。

01/1|<<1>>|