JS数字转换为EXCEL字母列的代码实现
程序员文章站
2022-11-03 17:27:31
js数字转换为excel字母列的代码教程
/**
* convert from numeric position to letter for column nam...
js数字转换为excel字母列的代码教程
/** * convert from numeric position to letter for column names in excel * @param {int} n column number * @return {string} column letter(s) name */ 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; }