Given a positive integer, convert it to the corresponding Excel column title. In Excel, columns are labeled A through Z for columns 1-26, then AA, AB, through AZ for 27-52, then BA, BB, and so on. For example, 1 maps to "A", 26 maps to "Z", 27 maps to "AA", 28 maps to "AB", and 703 maps to "AAA". Return null for null input, and an empty string for values less than 1.
Examples:
Input: columnNumber = 1
Output: 'A'
Explanation: Column 1 maps to the first letter A
Input: columnNumber = 26
Output: 'Z'
Explanation: Column 26 maps to the last single letter Z
Input: columnNumber = 28
Output: 'AB'
Explanation: Column 28 maps to AB (27=AA, 28=AB)
Input: columnNumber = 703
Output: 'AAA'
Explanation: Column 703 maps to AAA
Input: columnNumber = null
Output: null
Explanation: Null input returns null
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.