How to get the column letter of a cell?

Viewed 6678

I have a cell of which I know the column number. I need to find out what is the corresponding letter using Apache POI.

String column_letter = newCellReference(cell).convertNumToColString(column_number);

This is what I've tried but it's not working.

1 Answers

CellReference.convertNumToColString is a static method. So no new CellReference object needed. And it needs the numeric column index from the cellwhich can be get via Cell.getColumnIndex.

So

String column_letter = CellReference.convertNumToColString(cell.getColumnIndex());
Related