Created
February 24, 2019 06:28
-
-
Save priesdelly/79c7be8fcced8653eaf93cd0c7d0a9d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string GetExcelColumnName(int columnNumber) | |
{ | |
int dividend = columnNumber; | |
string columnName = String.Empty; | |
int modulo; | |
while (dividend > 0) | |
{ | |
modulo = (dividend - 1) % 26; | |
columnName = Convert.ToChar(65 + modulo).ToString() + columnName; | |
dividend = (int)((dividend - modulo) / 26); | |
} | |
return columnName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment