Search code examples
apache-poixssf

Apache POI - XSSF: Row.getCell()


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?


Solution

  • 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") );