@Override
public ValueEval evaluateArray(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
- if (args.length != 1) {
- return ErrorEval.VALUE_INVALID;
+ if (args.length == 1) {
+ return evaluateOneArrayArg(args[0], srcRowIndex, srcColumnIndex,
+ vA -> evaluate(new ValueEval[]{vA}, srcRowIndex, srcColumnIndex));
+ } else if (args.length == 2) {
+ return evaluateTwoArrayArgs(args[0], args[1], srcRowIndex, srcColumnIndex,
+ (vA, vB) -> evaluate(new ValueEval[]{vA, vB}, srcRowIndex, srcColumnIndex));
}
- return evaluateOneArrayArg(args[0], srcRowIndex, srcColumnIndex,
- vA -> evaluate(new ValueEval[]{vA}, srcRowIndex, srcColumnIndex));
+ return ErrorEval.VALUE_INVALID;
}
private static ValueEval evaluateFalse(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.OperationEvaluationContext;
+import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.apache.poi.ss.util.Utils.assertBoolean;
import static org.apache.poi.ss.util.Utils.assertDouble;
import static org.apache.poi.ss.util.Utils.assertString;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests for {@link BooleanFunction#OR}
}
}
+ @Test
+ void testBug65915ArrayFunction() throws IOException {
+ //https://bz.apache.org/bugzilla/show_bug.cgi?id=65915
+ try (HSSFWorkbook wb = new HSSFWorkbook()) {
+ HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
+ HSSFSheet sheet = wb.createSheet();
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell cell = row.createCell(0);
+ sheet.setArrayFormula("INDEX({1},1,IF(OR(FALSE,FALSE),1,1))", new CellRangeAddress(0, 0, 0, 0));
+ fe.evaluateAll();
+ assertEquals(1.0, cell.getNumericCellValue());
+ }
+ }
+
private HSSFWorkbook initWorkbook1() {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();