Examples of FuncVarPtg


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

    AttrPtg ptgGoto2 = (AttrPtg) asts[7];   
    assertEquals("Goto 2 Length", (short)3, ptgGoto2.getData());
   
    assertEquals("If FALSE offset", (short)7, ifPtg.getData());
   
    FuncVarPtg funcPtg = (FuncVarPtg)asts[8];
   
   
  }
View Full Code Here

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

    assertTrue("Single Value is not an IntPtg", (asts[4] instanceof IntPtg));
    IntPtg intPtg = (IntPtg)asts[4];
    assertEquals("Result", (short)10, intPtg.getValue());
   
    assertTrue("Ptg is not a Variable Function", (asts[6] instanceof FuncVarPtg));
    FuncVarPtg funcPtg = (FuncVarPtg)asts[6];
    assertEquals("Arguments", 2, funcPtg.getNumberOfOperands());
   
   
  }
View Full Code Here

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

  public void testComplexIRR_bug45041() {
    String formula = "(1+IRR(SUMIF(A:A,ROW(INDIRECT(MIN(A:A)&\":\"&MAX(A:A))),B:B),0))^365-1";
    Ptg[] ptgs = FormulaParser.parse(formula, null);

    FuncVarPtg rowFunc = (FuncVarPtg) ptgs[10];
    FuncVarPtg sumifFunc = (FuncVarPtg) ptgs[12];
    assertEquals("ROW", rowFunc.getName());
    assertEquals("SUMIF", sumifFunc.getName());

    if (rowFunc.getPtgClass() == Ptg.CLASS_VALUE || sumifFunc.getPtgClass() == Ptg.CLASS_VALUE) {
      throw new AssertionFailedError("Identified bug 45041");
    }
    confirmTokenClass(ptgs, 1, Ptg.CLASS_REF);
    confirmTokenClass(ptgs, 2, Ptg.CLASS_REF);
    confirmFuncClass(ptgs, 3, "MIN", Ptg.CLASS_VALUE);
View Full Code Here

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

        AttrPtg attrPtg = (AttrPtg) ptg;
        if (attrPtg.isSum()) {
          // Excel prefers to encode 'SUM()' as a tAttr token, but this evaluator
          // expects the equivalent function token
          byte nArgs = 1// tAttrSum always has 1 parameter
          ptg = new FuncVarPtg("SUM", nArgs);
        }
      }
      if (ptg instanceof ControlPtg) {
        // skip Parentheses, Attr, etc
        continue;
View Full Code Here

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

    Ptg[] ptgs = {
        new RefPtg("C1"),
        new RefPtg("C1"),
        new IntPtg(0),
        new RefPtg("B1"),
        new FuncVarPtg("OFFSET", (byte)3),
        RangePtg.instance,
        AttrPtg.SUM,
      };
    fr.setParsedExpression(ptgs);
  }
View Full Code Here

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

    AttrPtg ptgGoto2 = (AttrPtg) asts[7];   
    assertEquals("Goto 2 Length", (short)3, ptgGoto2.getData());
   
    assertEquals("If FALSE offset", (short)7, ifPtg.getData());
   
    FuncVarPtg funcPtg = (FuncVarPtg)asts[8];
   
   
  }
View Full Code Here

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

    assertTrue("Single Value is not an IntPtg", (asts[4] instanceof IntPtg));
    IntPtg intPtg = (IntPtg)asts[4];
    assertEquals("Result", (short)10, intPtg.getValue());
   
    assertTrue("Ptg is not a Variable Function", (asts[6] instanceof FuncVarPtg));
    FuncVarPtg funcPtg = (FuncVarPtg)asts[6];
    assertEquals("Arguments", 2, funcPtg.getNumberOfOperands());
   
   
  }
View Full Code Here

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

    assertEquals(AttrPtg.class,    fr.getParsedExpression().get(10).getClass());
    assertEquals(ReferencePtg.class, fr.getParsedExpression().get(11).getClass());
    assertEquals(AttrPtg.class,    fr.getParsedExpression().get(12).getClass());
    assertEquals(FuncVarPtg.class,   fr.getParsedExpression().get(13).getClass());
   
    FuncVarPtg choose = (FuncVarPtg)fr.getParsedExpression().get(13);
    assertEquals("CHOOSE", choose.getName());
  }
View Full Code Here

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

            }
            // must be external function
            ParseNode[] allArgs = new ParseNode[numArgs+1];
            allArgs[0] = new ParseNode(namePtg);
            System.arraycopy(args, 0, allArgs, 1, numArgs);
            return new ParseNode(new FuncVarPtg(name, (byte)(numArgs+1)), allArgs);
        }

        if (namePtg != null) {
            throw new IllegalStateException("NamePtg no applicable to internal functions");
        }
        boolean isVarArgs = !fm.hasFixedArgsLength();
        int funcIx = fm.getIndex();
        if (funcIx == FunctionMetadataRegistry.FUNCTION_INDEX_SUM && args.length == 1) {
            // Excel encodes the sum of a single argument as tAttrSum
            // POI does the same for consistency, but this is not critical
            return new ParseNode(AttrPtg.getSumSingle(), args);
            // The code below would encode tFuncVar(SUM) which seems to do no harm
        }
        validateNumArgs(args.length, fm);

        AbstractFunctionPtg retval;
        if(isVarArgs) {
            retval = new FuncVarPtg(name, (byte)numArgs);
        } else {
            retval = new FuncPtg(funcIx);
        }
        return new ParseNode(retval, args);
    }
View Full Code Here

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

    }
   
    if (isSingleArgSum(token)) {
      // Need to process the argument of SUM with transformFunctionNode below
      // so make a dummy FuncVarPtg for that call.
      token = new FuncVarPtg("SUM", (byte)1);
      // Note - the tAttrSum token (node.getToken()) is a base
      // token so does not need to have its operand class set
    }
    if (token instanceof ValueOperatorPtg || token instanceof ControlPtg
        || token instanceof MemFuncPtg
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.