poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aju Mathai <mathai...@gmail.com>
Subject Problem reading XLS files
Date Thu, 21 Jan 2010 09:16:55 GMT
Hi,

I am using the following POI libraries to read in the files with .xls
and .xlsx files. I found a strange problem ,the celliterator.hasNext()
sometimes gives true even if the next column in my xls file seems to
be blank, i have no additional columns. How do i take care of such
blank cells ?

Here is my code snippet

                    for(Iterator<Cell> ri = row.cellIterator();
ri.hasNext();)  {
			  Cell cell = ri.next();
			
				switch(cell.getCellType()){
				case Cell.CELL_TYPE_STRING:
					text.append(cell.getRichStringCellValue().getString().trim());
					break;
				case Cell.CELL_TYPE_NUMERIC:
					text.append(cell.getNumericCellValue());
					break;
				case Cell.CELL_TYPE_BOOLEAN:
					text.append(cell.getBooleanCellValue());
					break;
				case Cell.CELL_TYPE_FORMULA:
					text.append(cell.getCellFormula());
					break;
				case Cell.CELL_TYPE_BLANK:
					break;
				default:
					text.append("");
				}
				// Column Delimiter
				if(ri.hasNext() &&  !(cell.getCellType() == Cell.CELL_TYPE_BLANK))
					text.append(COLUMN_DELIMITER);
			}


Thanks
mathaj

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


Mime
View raw message