Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get columns' names in Excel file using Apache POI

How to get the column names in an Excel file using Apache POI, to make sure that the columns are ordered as expected.

like image 823
Mahmoud Saleh Avatar asked Nov 20 '11 14:11

Mahmoud Saleh


People also ask

How do I get a list of column names in Excel?

Just click the Navigation Pane button under Kutools Tab, and it displays the Navigation pane at the left. Under the Column Tab, it lists all column header names.


1 Answers

There is a convenience method for this:

CellReference.convertNumToColString(cell.getColumnIndex());

To get the full name:

private static String getCellName(Cell cell)
{
    return CellReference.convertNumToColString(cell.getColumnIndex()) + (cell.getRowIndex() + 1);
}
like image 92
wvdz Avatar answered Sep 22 '22 08:09

wvdz