How to convert a column number (e.g. 127) into an Excel column (e.g. AA)

前端 未结 30 2093
鱼传尺愫
鱼传尺愫 2020-11-22 00:35

How do you convert a numerical number to an Excel column name in C# without using automation getting the value directly from Excel.

Excel 2007 has a possible range o

30条回答
  •  不思量自难忘°
    2020-11-22 00:59

    After looking at all the supplied Versions here, i descided to do one myself, using recursion.

    Here is my vb.net Version:

    Function CL(ByVal x As Integer) As String
        If x >= 1 And x <= 26 Then
            CL = Chr(x + 64)
        Else
            CL = CL((x - x Mod 26) / 26) & Chr((x Mod 26) + 1 + 64)
        End If
    End Function
    

提交回复
热议问题