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

Examples of org.apache.poi.hssf.record.formula.ReferencePtg


                }
                Eval opresult = operation.evaluate(ops, srcRowNum, srcColNum);
                stack.push(opresult);
            }
            else if (ptgs[i] instanceof ReferencePtg) {
                ReferencePtg ptg = (ReferencePtg) ptgs[i];
                short colnum = ptg.getColumn();
                short rownum = ptg.getRow();
                HSSFRow row = sheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef2DEval(ptg, stack, cell, row, sheet, workbook);
            }
            else if (ptgs[i] instanceof Ref3DPtg) {
                Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
                short colnum = ptg.getColumn();
                short rownum = ptg.getRow();
                Workbook wb = workbook.getWorkbook();
                HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(ptg.getExternSheetIndex()));
                HSSFRow row = xsheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
            }
            else if (ptgs[i] instanceof AreaPtg) {
View Full Code Here


                }
                Eval opresult = invokeOperation(operation, ops, srcRowNum, srcColNum, workbook, sheet);
                stack.push(opresult);
            }
            else if (ptg instanceof ReferencePtg) {
                ReferencePtg refPtg = (ReferencePtg) ptg;
                int colIx = refPtg.getColumn();
                int rowIx = refPtg.getRow();
                HSSFRow row = sheet.getRow(rowIx);
                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef2DEval(refPtg, cell, row, sheet, workbook));
            }
            else if (ptg instanceof Ref3DPtg) {
                Ref3DPtg refPtg = (Ref3DPtg) ptg;
                int colIx = refPtg.getColumn();
                int rowIx = refPtg.getRow();
                Workbook wb = workbook.getWorkbook();
                HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(refPtg.getExternSheetIndex()));
                HSSFRow row = xsheet.getRow(rowIx);
                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef3DEval(refPtg, cell, row, xsheet, workbook));
            }
            else if (ptg instanceof AreaPtg) {
View Full Code Here

                    // Look for references, and update if needed
                    Ptg[] ptgs = fp.getRPNPtg();
                    boolean changed = false;
                    for(int i=0; i<ptgs.length; i++) {
                        if(ptgs[i] instanceof ReferencePtg) {
                            ReferencePtg rptg = (ReferencePtg)ptgs[i];
                            if(startRow <= rptg.getRowAsInt() &&
                                    rptg.getRowAsInt() <= endRow) {
                                // References a row that moved
                                rptg.setRow(rptg.getRowAsInt() + n);
                                changed = true;
                            }
                        }
                    }
                    // If any references were changed, then
View Full Code Here

        new NumberEval(25),
        new NumberEval(25),
    };
    Area2DEval arg0 = new Area2DEval(new AreaPtg("C1:C6"), values);
   
    Ref2DEval criteriaArg = new Ref2DEval(new ReferencePtg("A1"), new NumberEval(25));
    Eval[] args=  { arg0, criteriaArg, };
   
    double actual = NumericFunctionInvoker.invoke(new Countif(), args);
    assertEquals(4, actual, 0D);
  }
View Full Code Here

    // text (first) arg type is number, other args are strings with fractional digits
    confirmMid(new NumberEval(123456), new StringEval("3.1"), new StringEval("2.9"), "34");
   
    // startPos is 1x1 area ref, numChars is cell ref
    AreaEval aeStart = new Area2DEval(new AreaPtg("A1:A1"), new ValueEval[] { new NumberEval(2), } );
    RefEval reNumChars = new Ref2DEval(new ReferencePtg("B1"), new NumberEval(3));
    confirmMid(new StringEval("galactic"), aeStart, reNumChars, "ala");

    confirmMid(new StringEval("galactic"), new NumberEval(3.1), BlankEval.INSTANCE, "");

    confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.FALSE, "");
View Full Code Here

  /**
   * Simulates call: T(A1)
   * where cell A1 has the specified innerValue
   */
  private Eval invokeTWithReference(ValueEval innerValue) {
    Eval arg = new Ref2DEval(new ReferencePtg((short)1, (short)1, false, false), innerValue);
    return invokeT(arg);
  }
View Full Code Here

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

    assertEquals(expected, nve.getNumberValue(), 0);
  }

  public void testScalarSimple() {
   
    RefEval refEval = new Ref2DEval(new ReferencePtg("A1"), new NumberEval(3));
    Eval[] args = {
      refEval,
      new NumberEval(2),
    };
    Eval result = invokeSumproduct(args);
View Full Code Here

                }
                Eval opresult = operation.evaluate(ops, srcRowNum, srcColNum);
                stack.push(opresult);
            }
            else if (ptgs[i] instanceof ReferencePtg) {
                ReferencePtg ptg = (ReferencePtg) ptgs[i];
                short colnum = ptg.getColumn();
                short rownum = ptg.getRow();
                HSSFRow row = sheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef2DEval(ptg, stack, cell, row, sheet, workbook);
            }
            else if (ptgs[i] instanceof Ref3DPtg) {
                Ref3DPtg ptg = (Ref3DPtg) ptgs[i];
                short colnum = ptg.getColumn();
                short rownum = ptg.getRow();
                Workbook wb = workbook.getWorkbook();
                HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(ptg.getExternSheetIndex()));
                HSSFRow row = xsheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
            }
            else if (ptgs[i] instanceof AreaPtg) {
View Full Code Here

                }
                Eval opresult = invokeOperation(operation, ops, srcRowNum, srcColNum, workbook, sheet);
                stack.push(opresult);
            }
            else if (ptg instanceof ReferencePtg) {
                ReferencePtg refPtg = (ReferencePtg) ptg;
                int colIx = refPtg.getColumn();
                int rowIx = refPtg.getRow();
                HSSFRow row = sheet.getRow(rowIx);
                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef2DEval(refPtg, cell, row, sheet, workbook));
            }
            else if (ptg instanceof Ref3DPtg) {
                Ref3DPtg refPtg = (Ref3DPtg) ptg;
                int colIx = refPtg.getColumn();
                int rowIx = refPtg.getRow();
                Workbook wb = workbook.getWorkbook();
                HSSFSheet xsheet = workbook.getSheetAt(wb.getSheetIndexFromExternSheetIndex(refPtg.getExternSheetIndex()));
                HSSFRow row = xsheet.getRow(rowIx);
                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef3DEval(refPtg, cell, row, xsheet, workbook));
            }
            else if (ptg instanceof AreaPtg) {
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.ReferencePtg

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.