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

    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 =;
            //For each row, iterate through each columns
           Iterator<Cell> cellIterator = row.cellIterator();
                Cell cell =;
                switch(cell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                   //     System.out.print(cell.getBooleanCellValue() + "\t\t");
                    case Cell.CELL_TYPE_NUMERIC:
                       // System.out.print(cell.getNumericCellValue() + "\t\t");
                    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:
                    case Cell.CELL_TYPE_BLANK:
                    case Cell.CELL_TYPE_NUMERIC:
                        bilancoVeriExcel = count;//next_Cell.getNumericCellValue();
                     case Cell.CELL_TYPE_STRING:
    Last edited by kaucuk; 07-15-2013 at 11:16 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: reading Excel repeated cells with Apache Poi

    Moved from New to Java.

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

    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, 10:36 AM
  2. Editing specific (existing) excel cells
    By bolbi123456 in forum Advanced Java
    Replies: 17
    Last Post: 05-19-2012, 04:13 AM
  3. Replies: 0
    Last Post: 11-17-2011, 10:33 AM
  4. Replies: 0
    Last Post: 05-11-2011, 12:49 PM
  5. Replies: 0
    Last Post: 11-06-2007, 07: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