AreaEval aeSum) {
// TODO - junit to prove last arg must be srcColumnIndex and not srcRowIndex
I_MatchPredicate mp = Countif.createCriteriaPredicate(arg1, srcRowIndex, srcColumnIndex);
+
+ // handle empty cells
+ if(mp == null) {
+ return NumberEval.ZERO;
+ }
+
double result = sumMatchingCells(aeRange, mp, aeSum);
return new NumberEval(result);
}
* SUMIF was throwing a NPE on some formulas
*/
@Test
- @Ignore("This bug is still to be fixed")
public void testBug56420SumIfNPE() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56420.xlsx");
Row r = sheet.getRow(2);
Cell c = r.getCell(2);
assertEquals("SUMIF($A$1:$A$4,A3,$B$1:$B$4)", c.getCellFormula());
- evaluator.evaluateInCell(c);
+ Cell eval = evaluator.evaluateInCell(c);
+ assertEquals(0.0, eval.getNumericCellValue(), 0.0001);
}
private void bug53798Work(Workbook wb, File xlsOutput) throws IOException {
import junit.framework.TestCase;
import org.apache.poi.ss.formula.eval.AreaEval;
+import org.apache.poi.ss.formula.eval.BlankEval;
+import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.NumericValueEval;
import org.apache.poi.ss.formula.eval.StringEval;
confirmDouble(60, ve);
}
+
+ public void testEvaluateException() {
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, BlankEval.instance, new NumberEval(30.0)));
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, BlankEval.instance, new NumberEval(30.0), new NumberEval(30.0)));
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, new NumberEval(30.0), BlankEval.instance, new NumberEval(30.0)));
+ assertEquals(ErrorEval.VALUE_INVALID, invokeSumif(-1, -1, new NumberEval(30.0), new NumberEval(30.0), BlankEval.instance));
+ }
}