Cherish_Now

导航

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

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 

posted on 2019-02-19 10:52  Cherish_Now  阅读(2709)  评论(0编辑  收藏  举报