This is trickier than it looks at first blush.
In Excel, columns have letter identifiers:
- 1st column is "A"
- 2nd is "B"
- ...
- 26th is "Z"
- 27th is "AA"
- 28th is "AB"
- ...
- "ZY"
- "ZZ"
- "AAA"
- ...
I am looking for the cleanest algorithm (i.e. the most readable) that can turn the column number into the column identifier.
I explicitely don't want a solution that works inside Excel. It needs to run standalone.
I have my solution, but am looking for other approaches.
Here are my (NUnit) test cases. They are correct, to the best of my knowledge.
[TestCase(1, "A")]
[TestCase(26, "Z")]
[TestCase(27, "AA")]
[TestCase(52, "AZ")]
[TestCase(53, "BA")]
[TestCase(702, "ZZ")]
[TestCase(703, "AAA")]
[TestCase(18278, "ZZZ")]
[TestCase(18279, "AAAA")]
[TestCase(475255, "AAAAA")]