Results 1 to 2 of 2
  1. #1
    kaucuk is offline Member
    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Default reading Excel repeated cells with Apache Poi

    gents, i have a problem reading excel file with while loop. Program works by matching a string value given then gets from an excel cell data and basically it works. But when there are two or more same string value, it continues the loop and get the last correspondent one. What i want to terminate after first or second and so on ... nevertheless i need hasNext(); do you have any clue?

    Java Code:
    while(rowIterator.hasNext() ) {
           
           
           Row row = rowIterator.next();
            
            //For each row, iterate through each columns
           
           Iterator<Cell> cellIterator = row.cellIterator();
           
            
            
            while(cellIterator.hasNext()){
                               
                Cell cell = cellIterator.next();
                
                switch(cell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                   //     System.out.print(cell.getBooleanCellValue() + "\t\t");
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                       // System.out.print(cell.getNumericCellValue() + "\t\t");
                        break;
                    case Cell.CELL_TYPE_STRING:
                  if (cell.getStringCellValue().equals(veri_Tipi)){ 
                                    
                                    CellReference nextCellAdress = new CellReference(row.getRowNum(),cell.getColumnIndex()+2);
                                    Row next_Cell_Row = sheet.getRow(nextCellAdress.getRow());
                                    Cell next_Cell = next_Cell_Row.getCell(nextCellAdress.getCol());
                                    
                     
                    switch(next_Cell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                        break;
                    case Cell.CELL_TYPE_BLANK:
                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        bilancoVeriExcel = count;//next_Cell.getNumericCellValue();
                   
                        break;
                     case Cell.CELL_TYPE_STRING:
                        break;
                                    }
                               
                                    } 
                
                }
                
                      }
            }
    Last edited by kaucuk; 07-15-2013 at 10:16 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: reading Excel repeated cells with Apache Poi

    Moved from New to Java.

    Use code tags, not quote tags, for posting code.
    Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 1
    Last Post: 05-29-2013, 09:36 AM
  2. Editing specific (existing) excel cells
    By bolbi123456 in forum Advanced Java
    Replies: 17
    Last Post: 05-19-2012, 03:13 AM
  3. Replies: 0
    Last Post: 11-17-2011, 09:33 AM
  4. Replies: 0
    Last Post: 05-11-2011, 11:49 AM
  5. Replies: 0
    Last Post: 11-06-2007, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •