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 / April 2006

Tip: Looking for answers? Try searching our database.

Jakarta POI APi

Thread view: 
canodabasioglu@gmail.com - 18 Apr 2006 16:12 GMT
I need to read an excel file and like others, I use Jakarta POI APi for
this purpose.
But the problem is that I have to know number of cells those contain
data before starting
the read so that I can stop reading when there is no more data. Null
check is not of use
because there may be blank cells among cells containing data.

Can you guide me the proper way of using POI that can solve my problem.

Thanks in advance.

Can Odabasioglu
Gordon Beaton - 18 Apr 2006 16:18 GMT
> I need to read an excel file and like others, I use Jakarta POI APi
> for this purpose. But the problem is that I have to know number of
[quoted text clipped - 4 lines]
> Can you guide me the proper way of using POI that can solve my
> problem.

Do these methods not do what you want?

 HSSFSheet.getFirstRowNum()
 HSSFSheet.getLastRowNum()

 HSSFRow.getFirstCellNum()
 HSSFRow.getLastCellNum()

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Rajah - 18 Apr 2006 16:30 GMT
Can,

I have written a small routine called isCellBlank. It looks like this:

   protected boolean isCellBlank(HSSFCell cell) {
       if (null == cell) return true; // If cell is null let's return
true.
       return (cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) ;
   }

I am not sure if you can distinguish between a null cell and a blank
cell that is in the midst of other, valid data. If so, you probably
want to multiply the physical number of rows by the number of columns.
You might want to use a snippet like this:

int  rows  = sheet.getPhysicalNumberOfRows();
               for (int r = 0; r < rows; r++)
               {
                   HSSFRow row   = sheet.getRow(r);
                   int     cells = row.getPhysicalNumberOfCells();
...
                  }

and accumulate the number of cells.


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



©2008 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.