Package org.apache.poi.hssf.record.formula.eval

Examples of org.apache.poi.hssf.record.formula.eval.Ref2DEval


  /**
   * Creates a single RefEval (with value zero)
   */
  public static RefEval createRefEval(String refStr) {
    return new Ref2DEval(new RefPtg(refStr), ZERO);
  }
View Full Code Here


     * Non existent cells are treated as RefEvals containing BlankEval.
     */
    private static Ref2DEval createRef2DEval(RefPtg ptg, Cell cell,
            Row row, Sheet sheet, Workbook workbook) {
        if (cell == null) {
            return new Ref2DEval(ptg, BlankEval.INSTANCE);
        }
       
        switch (cell.getCellType()) {
            case Cell.CELL_TYPE_NUMERIC:
                return new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue()));
            case Cell.CELL_TYPE_STRING:
                return new Ref2DEval(ptg, new StringEval(cell.getRichStringCellValue().getString()));
            case Cell.CELL_TYPE_FORMULA:
                return new Ref2DEval(ptg, internalEvaluate(cell, row, sheet, workbook));
            case Cell.CELL_TYPE_BOOLEAN:
                return new Ref2DEval(ptg, BoolEval.valueOf(cell.getBooleanCellValue()));
            case Cell.CELL_TYPE_BLANK:
                return new Ref2DEval(ptg, BlankEval.INSTANCE);
            case Cell.CELL_TYPE_ERROR:
                return new  Ref2DEval(ptg, ErrorEval.valueOf(cell.getErrorCellValue()));
        }
        throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
    }
View Full Code Here

    protected static void pushRef2DEval(ReferencePtg ptg, Stack stack,
            HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) {
        if (cell != null)
            switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_NUMERIC:
                stack.push(new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue()), false));
                break;
            case HSSFCell.CELL_TYPE_STRING:
                stack.push(new Ref2DEval(ptg, new StringEval(cell.getStringCellValue()), false));
                break;
            case HSSFCell.CELL_TYPE_FORMULA:
                stack.push(new Ref2DEval(ptg, internalEvaluate(cell, row, sheet, workbook), true));
                break;
            case HSSFCell.CELL_TYPE_BOOLEAN:
                stack.push(new Ref2DEval(ptg, cell.getBooleanCellValue() ? BoolEval.TRUE : BoolEval.FALSE, false));
                break;
            case HSSFCell.CELL_TYPE_BLANK:
                stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
                break;
            case HSSFCell.CELL_TYPE_ERROR:
                stack.push(new Ref2DEval(ptg, ErrorEval.UNKNOWN_ERROR, false)); // TODO: think abt this
                break;
            }
        else {
            stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
        }
    }
View Full Code Here

    protected static void pushRef2DEval(ReferencePtg ptg, Stack stack,
            HSSFCell cell, HSSFRow row, HSSFSheet sheet, HSSFWorkbook workbook) {
        if (cell != null)
            switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_NUMERIC:
                stack.push(new Ref2DEval(ptg, new NumberEval(cell.getNumericCellValue()), false));
                break;
            case HSSFCell.CELL_TYPE_STRING:
                stack.push(new Ref2DEval(ptg, new StringEval(cell.getRichStringCellValue().getString()), false));
                break;
            case HSSFCell.CELL_TYPE_FORMULA:
                stack.push(new Ref2DEval(ptg, internalEvaluate(cell, row, sheet, workbook), true));
                break;
            case HSSFCell.CELL_TYPE_BOOLEAN:
                stack.push(new Ref2DEval(ptg, cell.getBooleanCellValue() ? BoolEval.TRUE : BoolEval.FALSE, false));
                break;
            case HSSFCell.CELL_TYPE_BLANK:
                stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
                break;
            case HSSFCell.CELL_TYPE_ERROR:
                stack.push(new Ref2DEval(ptg, ErrorEval.UNKNOWN_ERROR, false)); // TODO: think abt this
                break;
            }
        else {
            stack.push(new Ref2DEval(ptg, BlankEval.INSTANCE, false));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.eval.Ref2DEval

Copyright © 2018 www.massapicom. 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.