Hi all,

While trying to parse an Excel file, I discovered something weird : when
using Iterator to iterate over the cells of a given row, the first cell is
never returned. Hence, when reading a document, the first column is never
read !

Here is the code:


                        POIFSFileSystem fs = new POIFSFileSystem( new
FileInputStream("C:/test/targets/test_rigolo97.xls") );
                        HSSFWorkbook wb = new HSSFWorkbook(fs);
                        HSSFSheet sheet = wb.getSheetAt(0);
                        HSSFRow row;
                        Iterator cells;
                        HSSFCell cell;
                        

                        Iterator rows = sheet.rowIterator(); 
                        while( rows.hasNext() ) {
                                row = (HSSFRow) rows.next();
                                System.out.println( "Row #" + row.getRowNum() );
                                
                                
                                cells = row.cellIterator();
                                
                                while( cells.hasNext() ) {
                                        cell = (HSSFCell) cells.next();
                                        System.out.println( "Cell #" + 
cell.getCellNum() );
                                        switch ( cell.getCellType() ) {
                                        case HSSFCell.CELL_TYPE_NUMERIC:
                                                System.out.println( 
cell.getNumericCellValue() );
                                                break;
                                        case HSSFCell.CELL_TYPE_STRING: 
                                                System.out.println( 
cell.getRichStringCellValue().getString() );
                                                break;
                                        default:
                                                System.out.println( "x");
                                        break;
                                        }
                                }// end of row
                        }
                
Here is the parsed document:

A1      B1      C1
A2      B2      C2
A3      B3      C3
A4      B4      C4



And here is the output:
Row #0
Cell #1
B1
Cell #2
C1
Row #1
Cell #1
B2
Cell #2
C2
Row #2
Cell #1
B3
Cell #2
C3
Row #3
Cell #1
B4
Cell #2
C4

No trace of Ai !

If I add
  forgottenCell = (HSSFCell) row.getCell(0);
before the iteration on rows, then everything works fine...

Any idea of what could happen ?
Is this a bug ?
-- 
View this message in context: 
http://www.nabble.com/-BUG---Parsing-an-Excel-file-tf2473872.html#a6898126
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to