Skip to main content

Posts

Showing posts with the label .Net

Get excel column name by a known integer number

I am sharing with you a small function that enables you to get excel column name by a known integer number. function 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; } Way to call methods string strRange = GetExcelColumnName(5); output strRange = E