Skip to content

Instantly share code, notes, and snippets.

@tansaku
Created October 26, 2012 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tansaku/3959565 to your computer and use it in GitHub Desktop.
Save tansaku/3959565 to your computer and use it in GitHub Desktop.
convert integer to spreadsheet column name, a, b, c, ... aa, etc.
function colName(n) {
var s = "";
while(n >= 0) {
s = String.fromCharCode(n % 26 + 97) + s;
n = Math.floor(n / 26) - 1;
}
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment