• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get only non-blank cells in excel by java Excel api  RSS feed

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

am trying to get total no.of rows from excel sheet with this code.

 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry,, please have a look on this ,,,ignore the previous one...


but am getting the "rows_containData " as some thing wrong say 100.. Not getting exactly the number of rows which are having data..
Please, please , tell me how to get that ???


thaks
indu
 
Sheriff
Posts: 21137
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not counting rows, you're counting cells. You need to stop the inner loop once you've found a non-null cell. Adding "break;" just below the increment of rows_containData should do the trick.
 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, but it displays the total no.of rows in the excel sheet(say 329, including blank rows)

my code is -->>>
 
Rob Spoor
Sheriff
Posts: 21137
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then apparently blank rows don't cause the cell's getContents() method to return null. You could check against being empty as well:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!