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

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


        Workbook w = new Workbook();
        FormulaParser fp = new FormulaParser("FOO()", w);
        fp.parse();
        Ptg[] ptg = fp.getRPNPtg();

        AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[0];
        assertEquals("externalflag", tfunc.getName());

        NamePtg tname = (NamePtg) ptg[1];
        assertEquals("FOO", tname.toFormulaString(w));
    }
View Full Code Here


    confirmFuncClass(ptgs, 14, "IRR", Ptg.CLASS_VALUE);
  }

  private void confirmFuncClass(Ptg[] ptgs, int i, String expectedFunctionName, byte operandClass) {
    confirmTokenClass(ptgs, i, operandClass);
    AbstractFunctionPtg afp = (AbstractFunctionPtg) ptgs[i];
    assertEquals(expectedFunctionName, afp.getName());
  }
View Full Code Here

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("FOO", tname.toFormulaString(w));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

    return false;
  }

  private static boolean isSimpleValueFunction(Ptg token) {
    if (token instanceof AbstractFunctionPtg) {
      AbstractFunctionPtg aptg = (AbstractFunctionPtg) token;
      if (aptg.getDefaultOperandClass() != Ptg.CLASS_VALUE) {
        return false;
      }
      int numberOfOperands = aptg.getNumberOfOperands();
      for (int i=numberOfOperands-1; i>=0; i--) {
        if (aptg.getParameterClass(i) != Ptg.CLASS_VALUE) {
          return false;
        }
      }
      return true;
    }
View Full Code Here

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("myFunc", tname.toFormulaString(book));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

        // the name gets encoded as the first arg
        NamePtg tname = (NamePtg) ptg[0];
        assertEquals("FOO", tname.toFormulaString(w));

        AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
        assertTrue(tfunc.isExternalFunction());
    }
View Full Code Here

   
    // Check critical things in the Ptg array encoding.
    if(!(ptgF instanceof AbstractFunctionPtg)) {
        throw new RuntimeException("function token missing");
    }
    AbstractFunctionPtg func = (AbstractFunctionPtg) ptgF;
    if(func.getFunctionIndex() == 255) {
      throw new AssertionFailedError("Failed to recognise built-in function in formula '"
          + formula + "'");
    }
    assertEquals(expPtgArraySize, ptgs.length);
    assertEquals(funcIx, func.getFunctionIndex());
    Class expCls = isVarArgFunc ? FuncVarPtg.class : FuncPtg.class;
    assertEquals(expCls, ptgF.getClass());
   
    // check that parsed Ptg array converts back to formula text OK
    HSSFWorkbook book = new HSSFWorkbook();
View Full Code Here

            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);
        }
View Full Code Here

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("myFunc", tname.toFormulaString(book));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

    return false;
  }

  private static boolean isSimpleValueFunction(Ptg token) {
    if (token instanceof AbstractFunctionPtg) {
      AbstractFunctionPtg aptg = (AbstractFunctionPtg) token;
      if (aptg.getDefaultOperandClass() != Ptg.CLASS_VALUE) {
        return false;
      }
      int numberOfOperands = aptg.getNumberOfOperands();
      for (int i=numberOfOperands-1; i>=0; i--) {
        if (aptg.getParameterClass(i) != Ptg.CLASS_VALUE) {
          return false;
        }
      }
      return true;
    }
View Full Code Here

TOP

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

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.