Find Excel column name from a given column number | C # program to find Excel column name from a given column number ;  ; Function to print Excel column name for a given column number ; To store result ( Excel column name ) ; 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 code
using System ; class GFG { static String reverse ( String input ) { char [ ] reversedString = input . ToCharArray ( ) ; Array . Reverse ( reversedString ) ; return new String ( reversedString ) ; } private static void printString ( int columnNumber ) { String columnName = " " ; while ( columnNumber > 0 ) { int rem = columnNumber % 26 ; if ( rem == 0 ) { columnName += " Z " ; columnNumber = ( columnNumber / 26 ) - 1 ; } else { columnName += ( char ) ( ( rem - 1 ) + ' A ' ) ; columnNumber = columnNumber / 26 ; } } columnName = reverse ( columnName ) ; Console . WriteLine ( columnName . ToString ( ) ) ; } public static void Main ( String [ ] args ) { printString ( 26 ) ; printString ( 51 ) ; printString ( 52 ) ; printString ( 80 ) ; printString ( 676 ) ; printString ( 702 ) ; printString ( 705 ) ; } }