Fastest function to generate Excel column letters in C#

前端 未结 21 1750
无人共我
无人共我 2020-11-29 02:30

What is the fastest c# function that takes and int and returns a string containing a letter or letters for use in an Excel function? For example, 1 returns \"A\", 26 return

21条回答
  •  一生所求
    2020-11-29 02:48

    Just use an Excel formula instead of a user-defined function (UDF) or other program, per Allen Wyatt (https://excel.tips.net/T003254_Alphabetic_Column_Designation.html):

    =SUBSTITUTE(ADDRESS(ROW(),COLUMN(),4),ROW(),"")
    

    (In my organization, using UDFs would be very painful.)

提交回复
热议问题