Description
CDN Search
75CDN jsDelivr
<!DOCTYPE html>
<html>

<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta charset="utf-8" />
	<title>索引转Excel列字母</title>
</head>

<body>
	<pre>
function excelColumnIndexAsLetter(n) {
    var cs = 'A'.charCodeAt(0);
    var len = 26;
    var s = "";
    while (n >= 0) {
        s = String.fromCharCode(n % len + cs) + s;
        n = Math.floor(n / len) - 1;
    }
    return s;
}

document.writeln(excelColumnIndexAsLetter(0)+',')
document.writeln(excelColumnIndexAsLetter(26)+',')
document.writeln(excelColumnIndexAsLetter(52)+',')
document.writeln(excelColumnIndexAsLetter(999)+',')
document.writeln(excelColumnIndexAsLetter(99999))
</pre>
</body>

</html>
var js = document.body.getElementsByTagName('pre')[0].innerText;
(new Function(js))();
pre{
    border: 1px solid #ddd;
    padding: 5px;
}