/// <summary> /// Gets the column letter of a given column number. /// </summary> /// <param name="columnNumber">The column number to translate into a column letter.</param> /// <param name="trimToAllowed">if set to <c>true</c> the column letter will be restricted to the allowed range.</param> /// <returns></returns> private static string NaiveGetColumnLetterFromNumber(int columnNumber, bool trimToAllowed = false) { if (trimToAllowed) { columnNumber = XLHelper.TrimColumnNumber(columnNumber); } columnNumber--; // Adjust for start on column 1 if (columnNumber <= 25) { return(letters[columnNumber]); } var firstPart = (columnNumber) / 26; var remainder = ((columnNumber) % 26) + 1; return(NaiveGetColumnLetterFromNumber(firstPart) + NaiveGetColumnLetterFromNumber(remainder)); }