Last active
December 24, 2015 18:59
-
-
Save surskitt/6846488 to your computer and use it in GitHub Desktop.
Converts an absolute column number to an excel column notation (A - XFD).
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
def col2letter(col): | |
if col > 0 and col <= 16384: | |
a1 = chr((col / 26 ** 2) + 64) * (col > 26 ** 2) | |
a2 = chr(((col % 26 ** 2) / 26 - (not col % 26)) + 64) * (col > 26) | |
a3 = chr((col % 26 + (26 * (not col % 26))) + 64) | |
return ''.join((a1, a2, a3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment