Find Excel column name from a given column number | Python program to find Excel column name from a given column number ; Function to print Excel column name for a given column number ; To store current index in str which is result ; Find remainder ; if remainder is 0 , then a ' Z ' must be there in output ; If remainder is non - zero ; Reverse the string and print result ; Driver program to test the above Function
MAX = 50 NEW_LINE def printString ( n ) : NEW_LINE INDENT string = [ " \0" ] * MAX NEW_LINE i = 0 NEW_LINE while n > 0 : NEW_LINE INDENT rem = n % 26 NEW_LINE if rem == 0 : NEW_LINE INDENT string [ i ] = ' Z ' NEW_LINE i += 1 NEW_LINE n = ( n / 26 ) - 1 NEW_LINE DEDENT else : NEW_LINE INDENT string [ i ] = chr ( ( rem - 1 ) + ord ( ' A ' ) ) NEW_LINE i += 1 NEW_LINE n = n / 26 NEW_LINE DEDENT DEDENT string [ i ] = ' \0' NEW_LINE string = string [ : : - 1 ] NEW_LINE print " " . join ( string ) NEW_LINE DEDENT printString ( 26 ) NEW_LINE printString ( 51 ) NEW_LINE printString ( 52 ) NEW_LINE printString ( 80 ) NEW_LINE printString ( 676 ) NEW_LINE printString ( 702 ) NEW_LINE printString ( 705 ) NEW_LINE