Created
September 18, 2018 08:47
-
-
Save w35l3y/defade5c5d408e84e7e8c2e0f528eb2a to your computer and use it in GitHub Desktop.
Obtém nome da coluna a partir do índice
This file contains 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 getColumnName (columnIndex) { | |
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
let base = chars.length; | |
let output = ""; | |
while (0 <= columnIndex) { | |
let remainder = columnIndex % base; | |
columnIndex = Math.floor((columnIndex - remainder - 1) / base); | |
output = chars[remainder] + output; | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment