C#根据数字获取Excel列名
作者:互联网
/// <summary> /// 获取Excel列名 /// </summary> /// <param name="columnNumber">从1开始的数字</param> /// <returns>列的序号,如:A、B、C、AA、BB</returns> public static 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; }
标签:26,modulo,columnName,C#,列名,Excel,int,dividend 来源: https://www.cnblogs.com/LTQ151/p/16669186.html