Apache POI - XSSF: Row.getCell()

naamadheya picture naamadheya · Oct 11, 2011 · Viewed 9.4k times · Source

I am using XSSF to access the .xlsx format. Extracting row data and cell data is being done by

Row.getCell(1) // to get the first cell data. 

Is there a way to access cells like

Row.getCell(A) or Row.getCell(AC). 

This will be very helpfull for me to access columns. Can any one tell me the way to do this?

Answer

Gagravarr picture Gagravarr · Oct 11, 2011

I think the main class you're looking for is CellReference - it handles converting between user facing references such as "B2" into file format references like row=1,col=1 . There's a static method on there that handles your exact use case, convertColStringToIndex

For your use case, you'd want code something like

 Cell c = row.getCell( CellReference.convertColStringToIndex("G") );