Examples of CellValue


Examples of org.apache.poi.ss.usermodel.CellValue

      case HSSFCell.CELL_TYPE_ERROR:
        return CellValue.getError(cell.getErrorCellValue());
      case HSSFCell.CELL_TYPE_FORMULA:
        return evaluateFormulaCellValue(cell);
      case HSSFCell.CELL_TYPE_NUMERIC:
        return new CellValue(cell.getNumericCellValue());
      case HSSFCell.CELL_TYPE_STRING:
        return new CellValue(cell.getRichStringCellValue().getString());
      case HSSFCell.CELL_TYPE_BLANK:
        return null;
    }
    throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

   */
  public int evaluateFormulaCell(Cell cell) {
    if (cell == null || cell.getCellType() != HSSFCell.CELL_TYPE_FORMULA) {
      return -1;
    }
    CellValue cv = evaluateFormulaCellValue(cell);
    // cell remains a formula cell, but the cached value is changed
    setCellValue(cell, cv);
    return cv.getCellType();
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

    if (cell == null) {
      return null;
    }
    HSSFCell result = (HSSFCell) cell;
    if (cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA) {
      CellValue cv = evaluateFormulaCellValue(cell);
      setCellValue(cell, cv);
      setCellType(cell, cv); // cell will no longer be a formula cell
    }
    return result;
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

   */
  private CellValue evaluateFormulaCellValue(Cell cell) {
    ValueEval eval = _bookEvaluator.evaluate(new HSSFEvaluationCell((HSSFCell)cell));
    if (eval instanceof NumberEval) {
      NumberEval ne = (NumberEval) eval;
      return new CellValue(ne.getNumberValue());
    }
    if (eval instanceof BoolEval) {
      BoolEval be = (BoolEval) eval;
      return CellValue.valueOf(be.getBooleanValue());
    }
    if (eval instanceof StringEval) {
      StringEval ne = (StringEval) eval;
      return new CellValue(ne.getStringValue());
    }
    if (eval instanceof ErrorEval) {
      return CellValue.getError(((ErrorEval)eval).getErrorCode());
    }
    throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

          System.out.println("\t" + c.substring(c.lastIndexOf('.')+1) );
        }
        System.out.println("-> " + cell.getCellFormula());
      }
     
      CellValue evalResult = eval.evaluate(cell);
      assertNotNull(evalResult);
    }
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

      HSSFRow row = sheet.getRow(rowIx);
      if(row == null) {
        continue;
      }
      HSSFCell cell = row.getCell(COL_IX_ACTUAL);
      CellValue cv = fe.evaluate(cell);
      double actualValue = cv.getNumberValue();
      double expectedValue = row.getCell(COL_IX_EXPECTED).getNumericCellValue();
      if (actualValue != expectedValue) {
        System.err.println("Problem with test case on row " + (rowIx+1) + " "
            + "Expected = (" + expectedValue + ") Actual=(" + actualValue + ") ");
        failureCount++;
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue


    cellB1.setCellValue(1.0); // range will be C1:D1

    HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
    CellValue cv;
    try {
      cv = fe.evaluate(cellA1);
    } catch (IllegalArgumentException e) {
      if (e.getMessage().equals("Unexpected ref arg class (org.apache.poi.ss.formula.LazyAreaEval)")) {
        throw new AssertionFailedError("Identified bug 46948");
      }
      throw e;
    }

    assertEquals(12.0, cv.getNumberValue(), 0.0);

    cellB1.setCellValue(2.0); // range will be C1:E1
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1);
    assertEquals(21.0, cv.getNumberValue(), 0.0);

    cellB1.setCellValue(0.0); // range will be C1:C1
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1);
    assertEquals(5.0, cv.getNumberValue(), 0.0);
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

    // were 4 and 1, this would represent a circular reference.  Prior to v3.2 POI would
    // 'fully' evaluate ref arguments before invoking operators, which raised the possibility of
    // cycles / StackOverflowErrors.
   

    CellValue cellValue = evaluateWithCycles(wb, testCell);
   
    assertTrue(cellValue.getCellType() == HSSFCell.CELL_TYPE_NUMERIC);
    assertEquals(2, cellValue.getNumberValue(), 0);
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

   
    HSSFRow row = sheet.createRow(0);
    HSSFCell testCell = row.createCell(0);
    testCell.setCellFormula("A1");

    CellValue cellValue = evaluateWithCycles(wb, testCell);
   
    confirmCycleErrorCode(cellValue);
  }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellValue

    row.createCell(1).setCellFormula("C1");
    row.createCell(2).setCellFormula("D1");
    HSSFCell testCell = row.createCell(3);
    testCell.setCellFormula("A1");

    CellValue cellValue = evaluateWithCycles(wb, testCell);
   
    confirmCycleErrorCode(cellValue);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.