欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-02-21 07:56:56
function createCellPos( n ){ var ordA = 'A'.charCodeAt(0); var ordZ = 'Z'.charCodeAt(0); var len = ordZ - ordA + 1; var s = ""; while( n >= 0 ) { s = ......

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