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