#NEWLINE# def get_column_letter( col_idx ) : #NEWLINE# #INDENT# "Convert a column number into a column letter (3 -> 'C')\n\n    Right shift the column col_idx by 26 to find column letters in reverse\n    order.  These numbers are 1-based, and can be converted to ASCII\n    ordinals by adding 64.\n\n    " #NEWLINE# if ( not ( 1 <= col_idx <= 18278 ) ) : #NEWLINE# #INDENT# msg = ( 'Column index out of bounds: %s' % col_idx ) #NEWLINE# raise ColumnStringIndexException ( msg ) #NEWLINE# #UNINDENT# ordinals = [ ] #NEWLINE# temp = col_idx #NEWLINE# while temp : #NEWLINE# #INDENT# ( quotient , remainder ) = divmod ( temp , 26 ) #NEWLINE# if ( remainder == 0 ) : #NEWLINE# #INDENT# quotient -= 1 #NEWLINE# remainder = 26 #NEWLINE# #UNINDENT# ordinals . append ( ( remainder + 64 ) ) #NEWLINE# temp = quotient #NEWLINE# #UNINDENT# ordinals . reverse ( ) #NEWLINE# return '' . join ( [ chr ( ordinal ) for ordinal in ordinals ] )