Hi.
Can you please help me with following issue:
public static class Resolver implements ICustomFunction {
private boolean isLocked;
public Resolver(boolean isLocked) {
this.isLocked = isLocked;
}
@Override
public Object calculateCustomFunction(String s, ArrayList paramList, ArrayList arrayList2) {
System.out.println(“Calc " + s);
if (isLocked) {
return 0.0;
}
Double r = 0d;
for (Object d : paramList) {
r += (Double)d;
}
System.out.println(s + " calculated to " + r);
return r;
}
}
public void calculationChainTest() {
try {
Workbook wb = new Workbook();
Worksheet ws = wb.getWorksheets().get(0);
Cells cells = ws.getCells();
wb.getSettings().setCreateCalcChain(true);
Cell a1 = cells.get(“A1”);
Cell a2 = cells.get(“A2”);
Cell a3 = cells.get(“A3”);
a2.setFormula(”=MYSUM(A1,5)");
a3.setFormula("=MYSUM(A2,3)");
a1.putValue(“1”, true);
a3.calculate(true, new Resolver(true));
outCells(a1, 1, a2, 6, a3, 9);
a1.putValue(“4”, true);
a3.calculate(true, new Resolver(false));
outCells(a1, 4, a2, 9, a3, 12);
} catch (Exception e) {
e.printStackTrace();
assertNull(e);
}
}
private void outCells(Cell a1, double a1val, Cell a2, double a2val, Cell a3, double a3val) {
assertEquals(a1val, a1.getDoubleValue());
assertEquals(a2val, a2.getDoubleValue());
assertEquals(a3val, a3.getDoubleValue());
}
a2 will no recalucated automatically on recalculation a3. I just have one way to resolve this issue - read all precendents of a3 and recalc it.
Best regards. Alexey