poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 59670] New: Sheet.getRow().getCell() gets the value from the next sheet along
Date Tue, 07 Jun 2016 14:38:16 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=59670

            Bug ID: 59670
           Summary: Sheet.getRow().getCell() gets the value from the next
                    sheet along
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: cbradford@lintottcs.co.uk

When using the HSSF library when I print the current sheet name it prints the
correct one. If I then get the cell value of a known cell in that sheet it will
return the value of the cell in the next sheet along.

How I get the sheet:
private static Sheet getSheet(Workbook wb, String sheetName){
        Sheet s = null;

        int numberOfSheets = workbook.getNumberOfSheets();

        for (int i = 0; i < numberOfSheets; i++) {

            s = wb.getSheet(sheetName);

            if( s.getSheetName().equals(sheetName)){
                return s;
            }
       }
       return s;
    }

How I get the cell value:
private static double getCellValue(Cell cell) {
        switch (cell.getCellType()) {
            case Cell.CELL_TYPE_NUMERIC:
                return cell.getNumericCellValue();
            case Cell.CELL_TYPE_BLANK:
                return 0;
        }
      return 0;
}

double DOLabour = getCellValue(s.getRow(16).getCell(4));

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


Mime
View raw message