标签:需要 ret return str 实用 sum ram 转换 count
C# 实现Excel(导出导入)非常实用的将数字转换成字母
/// <summary>
/// 需要转换的行或者列
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
private static string NunberToChar(int index)
{
index = index - 1;
if (index < 0) { throw new Exception("invalid parameter"); }
List<string> chars = new List<string>();
do
{
if (chars.Count > 0) index--;
chars.Insert(0, ((char)(index % 26 + (int)‘A‘)).ToString());
index = (int)((index - index % 26) / 26);
} while (index > 0);
return String.Join(string.Empty, chars.ToArray());
}
标签:需要 ret return str 实用 sum ram 转换 count
原文地址:https://www.cnblogs.com/HF520134/p/9897951.html