Fixed #60858, which showed a regression of the fix for #56420 introduced by my refactoring to fix #56822.

Includes new unit test based on the bug sample file.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1786953 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Greg Woolsey 2017-03-14 21:39:33 +00:00
parent e13f7dc8af
commit 6349d2c614
2 changed files with 33 additions and 1 deletions

View File

@ -135,7 +135,8 @@ import org.apache.poi.ss.formula.functions.Countif.ErrorMatcher;
AreaEval aeRange = ranges[i];
I_MatchPredicate mp = predicates[i];
if (!mp.matches(aeRange.getRelativeValue(r, c))) {
// Bugs 60858 and 56420 show predicate can be null
if (mp == null || !mp.matches(aeRange.getRelativeValue(r, c))) {
matches = false;
break;
}

View File

@ -0,0 +1,31 @@
package org.apache.poi.ss.formula.functions;
import static org.junit.Assert.assertEquals;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.junit.Test;
/**
*
*/
public class TestSumifsXSSF {
/**
* handle null cell predicate
*/
@Test
public void testBug60858() {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("bug60858.xlsx");
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
Sheet sheet = wb.getSheetAt(0);
Cell cell = sheet.getRow(1).getCell(5);
fe.evaluate(cell);
assertEquals(0.0, cell.getNumericCellValue(), 0.0000000000000001);
}
}