Examples of FreeRefFunction


Examples of org.apache.poi.hssf.record.formula.functions.FreeRefFunction

    if(nIncomingArgs < 1) {
      throw new RuntimeException("function name argument missing");
    }
   
    Eval nameArg = args[0];
    FreeRefFunction targetFunc;
    try {
      if (nameArg instanceof NameEval) {
        targetFunc = findInternalUserDefinedFunction((NameEval) nameArg);
      } else if (nameArg instanceof NameXEval) {
        targetFunc = findExternalUserDefinedFunction(workbook, (NameXEval) nameArg);
      } else {
        throw new RuntimeException("First argument should be a NameEval, but got ("
            + nameArg.getClass().getName() + ")");
      }
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
    int nOutGoingArgs = nIncomingArgs -1;
    Eval[] outGoingArgs = new Eval[nOutGoingArgs];
    System.arraycopy(args, 1, outGoingArgs, 0, nOutGoingArgs);
    return targetFunc.evaluate(outGoingArgs, workbook, srcCellSheet, srcCellRow, srcCellCol);
  }
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.functions.FreeRefFunction

    if(false) {
      System.out.println("received call to external user defined function (" + functionName + ")");
    }
    // currently only looking for functions from the 'Analysis TookPak'  e.g. "YEARFRAC" or "ISEVEN"
    // not sure how much this logic would need to change to support other or multiple add-ins.
    FreeRefFunction result = AnalysisToolPak.findFunction(functionName);
    if (result != null) {
      return result;
    }
    throw new EvaluationException(ErrorEval.FUNCTION_NOT_IMPLEMENTED);
  }
View Full Code Here

Examples of org.apache.poi.hssf.record.formula.functions.FreeRefFunction

   
    return m;
  }

  private static void r(Map m, String functionName, FreeRefFunction pFunc) {
    FreeRefFunction func = pFunc == null ? NotImplemented : pFunc;
    m.put(functionName, func);
  }
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

    public void testAddNameX(){
        InternalWorkbook wb = TestHSSFWorkbook.getInternalWorkbook(new HSSFWorkbook());
        assertNotNull(wb.getNameXPtg("ISODD", UDFFinder.DEFAULT));

        FreeRefFunction NotImplemented = new FreeRefFunction() {
            public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
                throw new RuntimeException("not implemented");
            }
        };
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

        super(usedToolPacks);
        _funcMap = new HashMap<Integer, String>();
    }

    public FreeRefFunction findFunction(String name) {
        FreeRefFunction func = super.findFunction(name);
        if (func != null) {
            int idx = getFunctionIndex(name);
            _funcMap.put(idx, name);
        }
        return func;
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

        Iterator<String> keysIt = xlsMacroList.keySet().iterator();
        int x = 0;
        while (keysIt.hasNext()) {
            String name = keysIt.next();
            FreeRefFunction function = xlsMacroList.get(name);
            names[x] = name;
            functions[x] = function;
        }

        UDFFinder udff1 = new DefaultUDFFinder(names, functions);
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

        return m;
    }

    private static void r(Map<String, FreeRefFunction> m, String functionName, FreeRefFunction pFunc) {
        FreeRefFunction func = pFunc == null ? new NotImplemented(functionName) : pFunc;
        m.put(functionName, func);
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

     */
    public static Collection<String> getSupportedFunctionNames(){
        AnalysisToolPak inst = (AnalysisToolPak)instance;
        Collection<String> lst = new TreeSet<String>();
        for(String name : inst._functionsByName.keySet()){
            FreeRefFunction func = inst._functionsByName.get(name);
            if(func != null && !(func instanceof NotImplemented)){
                lst.add(name);
            }
        }
        return Collections.unmodifiableCollection(lst);
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

     */
    public static Collection<String> getNotSupportedFunctionNames(){
        AnalysisToolPak inst = (AnalysisToolPak)instance;
        Collection<String> lst = new TreeSet<String>();
        for(String name : inst._functionsByName.keySet()){
            FreeRefFunction func = inst._functionsByName.get(name);
            if(func != null && (func instanceof NotImplemented)){
                lst.add(name);
            }
        }
        return Collections.unmodifiableCollection(lst);
View Full Code Here

Examples of org.apache.poi.ss.formula.functions.FreeRefFunction

                        "Use FunctoinEval.registerFunction(String name, Function func) instead.");
            }

            throw new IllegalArgumentException(name + " is not a function from the Excel Analysis Toolpack.");
        }
        FreeRefFunction f = inst.findFunction(name);
        if(f != null && !(f instanceof NotImplemented)) {
            throw new IllegalArgumentException("POI already implememts " + name +
                    ". You cannot override POI's implementations of Excel functions");
        }
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.