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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to