Given a columns’ index, how can you get an Excel column name?
The problem is trickier than it sounds because it’s not just base-26. The columns don’t wrap over like normal digits would. Even the Microsoft Support Example doesn’t scale beyond ZZZ.
Disclaimer: This is some code I had done a while back, and it came across my desktop again today. I thought it was worthy of posting here as a pre-answered question.
The answer I came up with is to get a little recursive. This code is in VB.Net:
And in C#:
The only downside it that it uses 1-indexed columns rather than 0-indexed.