1 package org.simantics.spreadsheet.graph.formula;
3 import java.util.HashMap;
6 import org.simantics.spreadsheet.graph.CellFormulaFunction;
7 import org.simantics.spreadsheet.graph.SpreadsheetBook;
9 public class SpreadsheetEvaluationEnvironment {
11 final private SpreadsheetBook book;
12 private Map<String, CellFormulaFunction<?>> functions = new HashMap<>();
13 public int iterationLimit = 100;
15 public SpreadsheetEvaluationEnvironment(SpreadsheetBook book) {
18 functions.put("MATCH", new MatchFormulaFunction());
19 functions.put("ISERROR",new IsErrorFormulaFunction());
20 functions.put("IFERROR",new IfErrorFormulaFunction());
21 functions.put("IF", new IfFormulaFunction());
22 functions.put("OR", new OrFormulaFunction());
23 functions.put("AND", new AndFormulaFunction());
24 functions.put("ROUND", new RoundFormulaFunction());
25 functions.put("ROUNDUP", new RoundupFormulaFunction());
26 functions.put("SQRT", new SqrtFormulaFunction());
27 functions.put("PI", new PiFormulaFunction());
28 functions.put("COUNTIF", new CountifFormulaFunction());
29 functions.put("SUM", new SumFormulaFunction());
30 functions.put("AVERAGE", new AverageFormulaFunction());
31 functions.put("SUMIF", new SumifFormulaFunction());
32 functions.put("VLOOKUP", new VlookupFormulaFunction());
33 functions.put("HLOOKUP", new HlookupFormulaFunction());
34 functions.put("TODAY", new TodayFormulaFunction());
35 functions.put("LINEST", new LinestFormulaFunction());
36 functions.put("GEOMEAN", new GeomeanFormulaFunction());
39 public CellFormulaFunction<?> getFunction(String name) {
40 return functions.get(name);
43 public SpreadsheetBook getBook() {
47 public static Map<SpreadsheetBook, SpreadsheetEvaluationEnvironment> INSTANCES = new HashMap<>();
49 public static SpreadsheetEvaluationEnvironment getInstance(SpreadsheetBook book) {
50 SpreadsheetEvaluationEnvironment env = INSTANCES.get(book);
52 env = new SpreadsheetEvaluationEnvironment(book);
53 INSTANCES.put(book, env);