Skip to content

Instantly share code, notes, and snippets.

@priesdelly
Created February 24, 2019 06:28
Show Gist options
  • Save priesdelly/79c7be8fcced8653eaf93cd0c7d0a9d4 to your computer and use it in GitHub Desktop.
Save priesdelly/79c7be8fcced8653eaf93cd0c7d0a9d4 to your computer and use it in GitHub Desktop.
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