27 lines
775 B
C#
27 lines
775 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace KssSmaPlaLib.IO.Excel
|
|
{
|
|
public static class ExcelColumnHelperUxer
|
|
{
|
|
public static string GetExcelColumnLetter(int columnNumber)
|
|
{
|
|
if (columnNumber < 1)
|
|
throw new ArgumentOutOfRangeException(nameof(columnNumber), "Column number must be >= 1");
|
|
|
|
string columnLetter = string.Empty;
|
|
while (columnNumber > 0)
|
|
{
|
|
columnNumber--; // Adjust for 0-indexed calculation
|
|
columnLetter = (char)('A' + (columnNumber % 26)) + columnLetter;
|
|
columnNumber /= 26;
|
|
}
|
|
return columnLetter;
|
|
}
|
|
}
|
|
}
|