Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Getting incorrect number of rows in Excel - POI

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to get all the cell values from two columns, all rows. (Eg: C,D columns) and show it in my java app.
But I'm not getting the exact number of rows.
There are only 4 rows but it shows 7 because of which i'm getting null pointer exception
Please review the code and suggest.



Thanks,
Krishna
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which version of POI are you using? Is getPhysicalRows the only method for getting a number of rows? Is there another similar API call? You also might need to check each row for null and skip processing that row if it is.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the javadocs of the getPhysicalNumberOfRows method. Then search for other occurrences of that method name on the same page to find the method that you should be using instead. Be sure to read the javadocs of that method as well.

Note that the same applies to HSSFRow.getPhysicalNumberOfCells.
 
machines help you to do more, but experience less. Experience this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!