Skip to content

Instantly share code, notes, and snippets.

@kuoe0
Created January 11, 2012 16:01
Show Gist options
  • Save kuoe0/1595344 to your computer and use it in GitHub Desktop.
Save kuoe0/1595344 to your computer and use it in GitHub Desktop.
const char* toExcelColumnName( int n ) {
string ret = "";
while ( n ) {
int x = n % 26;
if ( x )
ret += 'A' + x - 1;
else
ret += 'Z', n -= 26;
n /= 26;
}
reverse( ret.begin(), ret.end() );
return ret.c_str();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment