Skip to content

Instantly share code, notes, and snippets.

@w35l3y
Created September 18, 2018 08:47
Show Gist options
  • Save w35l3y/defade5c5d408e84e7e8c2e0f528eb2a to your computer and use it in GitHub Desktop.
Save w35l3y/defade5c5d408e84e7e8c2e0f528eb2a to your computer and use it in GitHub Desktop.
Obtém nome da coluna a partir do índice
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