Bug 57869 - getRow() returns null even when there is data
Summary: getRow() returns null even when there is data
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2015-04-28 20:30 UTC by Ashok R
Modified: 2015-04-28 21:53 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Ashok R 2015-04-28 20:30:38 UTC
Im trying read a excel using HSSF which is a standard template used for populating the logs. But getRow() on the sheet object is returning a null value which looks weird. Here's my snippet:

fs 	= new NPOIFSFileSystem( new File( filePath + templateFile ), true );
wb 	= new HSSFWorkbook( fs.getRoot(), true );
sheet 	= wb.getSheetAt(0); //get first worksheet

//The following method is called to populate the sheet
populateLogFields( "", sheet.getRow(15) ); //Bank LOCKBX

The above line is getting failed which is getting the row as null. Not sure why it behaves like this. Kindly do review it from your end.

Ashok R
Comment 1 Nick Burch 2015-04-28 21:53:13 UTC
Rows in POI are 0-based not 1-based, so for row 15 in Excel, you need to call getRow(14)

Additionally, fetching sheet by name might be safer, in case there are hidden sheets before the one you think is the first

Otherwise, if that isn't the problem, please re-open and upload a file that shows the problem, along with a small junit unit test that shows it, and we'll take a look