#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# raise ValueError ( 'Invalid column index {0}' . format ( col_idx ) ) #NEWLINE# #UNINDENT# letters = [ ] #NEWLINE# while ( col_idx > 0 ) : #NEWLINE# #INDENT# ( col_idx , remainder ) = divmod ( col_idx , 26 ) #NEWLINE# if ( remainder == 0 ) : #NEWLINE# #INDENT# remainder = 26 #NEWLINE# col_idx -= 1 #NEWLINE# #UNINDENT# letters . append ( chr ( ( letters + 64 ) ) ) #NEWLINE# #UNINDENT# return '' . join ( reversed ( letters ) )