Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

Having issues reading excle with some empty rows

Thread view: 
prashantmantri@gmail.com - 04 Aug 2006 16:48 GMT
I am trying to read excel file using POI with code which looks as
follows

           HSSFWorkbook wb = new HSSFWorkbook(stream, false);
            HSSFSheet sheet = wb.getSheetAt(sheetNo);
               int noOfRows = sheet.getPhysicalNumberOfRows();
               for (int r = 0; r < noOfRows; r++) {

                   HSSFRow row = sheet.getRow(r);
                   if(row == null) break;
                   //read data

               }

What happens is if say I have an excel with 10 rows then i select the
data in last 5 row and delete it and save the excel. Now if I read the
excle again I assume that
int noOfRows = sheet.getPhysicalNumberOfRows(); should give me 5. But
still give me 10 and hence my program fails.

Anyone knows how to handle it?
Oliver Wong - 04 Aug 2006 20:10 GMT
>I am trying to read excel file using POI with code which looks as
> follows
[quoted text clipped - 17 lines]
>
> Anyone knows how to handle it?

   Look at the contents of the rows. They probably have empty strings, or
null or something. Come up with a rule to differentiate "fake" rows from
"real" rows. Implement your count manually based on that rule.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.