aspose file tools
The moose likes Java in General and the fly likes how to get only non-blank cells in excel by java Excel api Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "how to get only non-blank cells in excel by java Excel api" Watch "how to get only non-blank cells in excel by java Excel api" New topic
Author

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

indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
Hi,

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


thanks,
indu
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
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
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
indu yeturu
Ranch Hand

Joined: Aug 27, 2008
Posts: 123
thank you, but it displays the total no.of rows in the excel sheet(say 329, including blank rows)

my code is -->>>
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

Then apparently blank rows don't cause the cell's getContents() method to return null. You could check against being empty as well:
 
 
subject: how to get only non-blank cells in excel by java Excel api
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com