How to get value from a specific cell from XLSX file using java Apache POI library

For example, to get E10 of the first worksheet:

wb.getSheetAt(0).getRow(9).getCell(4); 

Note: subtract one because the indices are null-based.

You can also use this convenience method to map E to 4.

wb.getSheetAt(0).getRow(9).getCell(CellReference.convertColStringToIndex("E"));

To get a value from a specific cell in excel you can use the below code line.

wb.getSheetAt(0).getRow(1).getCell(1);

XSSFSheet has the method getRow(int rownum) It returns the logical row ( 0-based). If you ask for a row that is not defined you get a null. This is to say row 4 represents the fifth row on a sheet.

Once you get the row, you can call getCell(int cellnum) method of XSSFRow object. It returns the cell at the given (0 based) index.

Tags:

Java

Excel