数字序号 转 字母序号
/* * 数字序号转字符串序号 0 => "A" */ function indexToString(index){ var charcode; return index.toString(26).split("").map(function(item,i){ charcode = item.charCodeAt(0); charcode+=(charcode>=97?10:49); return String.fromCharCode(charcode) }).join("").toUpperCase(); } /* * 字符串序号转数字序号 "A" => 0 */ function stringToIndex(str){ var charcode; return parseInt(str.toLowerCase().split("").map(function(item,i){ charcode = item.charCodeAt(0); charcode-=(charcode<107?49:10); return String.fromCharCode(charcode) }).join(""),26); } indexToString(984284) => "CEABC" stringToIndex("CEABC") => 984284
原文链接:https://blog.csdn.net/zq1988626/article/details/90693723