Created
December 27, 2017 03:30
-
-
Save black-black-cat/0d30af892747ec5ab879b3247a73368b to your computer and use it in GitHub Desktop.
将数字转换成Excel列数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toColStr(n) { | |
str = '' | |
while (n > 0) { | |
var mod = (n-1) % 26 | |
n = Math.floor( (n-1)/26 ) | |
str = String.fromCharCode( mod + 65 ) + str | |
} | |
return str | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment