poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danny Mui <da...@muibros.com>
Subject Re: Row Iterator Problem
Date Wed, 18 Feb 2004 18:16:47 GMT
Is this for version 2?  Pleas submit a bugzilla report with a sample 
spreadsheet and of course the code to reproduce.

Thanks.

Anshul Patni wrote:
> Hii,
> I am also facing the same problem. The problem is: with the following for loop the iterator
is not going to the last row 
>  
> 
> for (HSSFRow row = (HSSFRow) rows.next();
> 
> rows.hasNext();
> 
> row = (HSSFRow) rows.next()) {
> }
> 
> I don't know exactly where the problem is. Can someone help??
>  
> Regards
> pats
> 
> Guest <vickansh@yahoo.com> wrote:
> Hii,
> 
> I still have the problem with row iterator...i have a method which gives me the 
> number of rows...it stops when it encountered empty cell > my defined columns
> 
> public int getNumberOfRows(HSSFSheet sheet, int numberOfColumns) {
> int count = 0;
> Iterator rows = (Iterator) sheet.rowIterator();
> for (HSSFRow row = (HSSFRow) rows.next();
> rows.hasNext();
> row = (HSSFRow) rows.next()) {
> logger.debug("Row No."+row.getRowNum());
> int nullOrBlankCells = 0;
> for (int j = 0; j < numberOfColumns; j++) {
> HSSFCell cell = row.getCell((short) j);
> if(isCellEmpty(cell)){
> nullOrBlankCells++;
> }
> } // iterate over columns finished
> 
> // if the row is empty break out of loop
> // and return the number of data rows
> if (nullOrBlankCells >= numberOfColumns)
> break;
> count++;
> }
> return count;
> }
> 
> private boolean isCellEmpty(HSSFCell cell) {
> return (cell == null)
> || (cell.getCellType() == HSSFCell.CELL_TYPE_BLANK)
> || (cell.getCellType() == HSSFCell.CELL_TYPE_STRING
> && cell.getStringCellValue().length() == 0);
> }
> 
> 
> Why the above doesn't work???
> 
> PLEASE HELP
> vicky
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail SpamGuard - Read only the mail you want.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org


Mime
View raw message