((SheetImpl)sheet1).setCellEditText(0,2,"=SUMPRODUCT({1,3;7,2}, {2,0;0,2})");//C1
assertEquals(6d, ((Number)cellC1.getResult()).doubleValue(), 0d);
}
//test SSDataListener (B1+D1)
public void testArithmeticUpdate() {
Sheet sheet1 = ((BookImpl)_book).addSheet("sheet1", 6, 6);
assertEquals(sheet1, _book.lookupSheet("sheet1"));
final SimpleSSDataListener ssl = new SimpleSSDataListener();
_book.addSSDataListener(ssl);
assertEquals(0, ssl.getList().size());
ssl.getList().clear();
((SheetImpl)sheet1).setCellValue(5,5, new FormulaImpl("=B1+D1")); //F6
ssl.getList().clear();
((SheetImpl)sheet1).setCellValue(0,1,new Integer(1)); //B1
assertCellEquals(sheet1.getCell(0, 1), 0, 1, new Integer(1));
assertEquals(2, ssl.getList().size());
ssl.getList().clear();
((SheetImpl)sheet1).setCellValue(0,3,new Integer(3)); //D1
assertCellEquals(sheet1.getCell(0, 3), 0, 3, new Integer(3));
assertEquals(2, ssl.getList().size());
ssl.getList().clear();
((SheetImpl)sheet1).setCellValue(0,2,new Integer(2)); //C1
assertCellEquals(sheet1.getCell(0, 2), 0, 2, new Integer(2));
assertEquals(1, ssl.getList().size());
ssl.getList().clear();
((SheetImpl)sheet1).getCell(0,1).setValue(5); //change B1 (1 -> 5) => F6.
System.out.println(Objects.toString(ssl.getList()));
assertEquals(2, ssl.getList().size());
for(final Iterator it = ssl.getList().iterator(); it.hasNext();) {
final SSDataEvent evt = (SSDataEvent) it.next();
final Range rng = evt.getRange();
if (rng.getLeft() == 1 && rng.getTop() == 0) {
assertEquals(5d, ((Number)sheet1.getCell(0,1).getResult()).doubleValue(), 0d);
} else if (rng.getLeft() == 5 && rng.getTop() == 5) {
assertEquals(8d, ((Number)sheet1.getCell(5,5).getResult()).doubleValue(), 0d);
} else {
assertFalse("should not come here", false);
}
}
}