Search code examples
c#excelnpoi

How to get excel column with the column index in NPOI C#


I want to set the cell formula for columns k-P by using a loop and in c# i can only loop with integers, how do you actually get the column(E.G K,L,M,N,O,P) with the index? for looping through rows its pretty easy because they are just numbers but for columns excel uses letters. I cant think of anything other than defining my own List for letters k-P in c#


Solution

  • You can use CellReference, if you already have the cell object.

    var temp = new CellReference(cell);
    var reference = temp.FormatAsString();
    

    Hope this works for you!