Fastest function to generate Excel column letters in C#

前端 未结 21 1782
无人共我
无人共我 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:51

    barrowc's idea is much more convenient and fastest than any conversion function! i have converted his ideas to actual c# code that i use:

      var start = m_xlApp.Cells[nRow1_P, nCol1_P];
      var end = m_xlApp.Cells[nRow2_P, nCol2_P];
      // cast as Range to prevent binding errors
      m_arrRange = m_xlApp.get_Range(start as Range, end as Range);
      object[] values = (object[])m_arrRange.Value2;
    

提交回复
热议问题