The GitHub Actions job "Java CI with Gradle" on poi.git/trunk has failed. Run started by GitHub user centic9 (triggered by centic9).
Head commit for run: be8875b18971cd63a885a697621eefc83df43128 / Dominik Stadler <[email protected]> Bug 60848 and 65907 - Fix SUMPRODUCT with unary minus (--) on array arguments and other cases SUMPRODUCT was failing with 'Invalid arg type for SUMPRODUCT: (org.apache.poi.ss.formula.eval.ErrorEval)' when the first argument was a unary-minus expression over a range, e.g. =SUMPRODUCT(--(B5:B20)). Root cause: Sumproduct did not implement the ArrayMode marker interface. WorkbookEvaluator looks ahead in the token stream for the enclosing function when evaluating each OperationPtg. If that function implements ArrayMode, it sets ec.setArrayMode(true), which causes ArrayFunction implementations (UnaryMinusEval, UnaryPlusEval, TwoOperandNumericOperation, RelationalOperationEval) to call evaluateArray() instead of the scalar evaluate(). Without ArrayMode on Sumproduct, unary minus fell back to scalar evaluation, which performed implicit intersection on the range. When the formula cell row/column did not intersect the range an ErrorEval was produced and passed to SUMPRODUCT as a first argument. Fix: - Make Sumproduct implement ArrayMode so that all operator expressions inside its arguments are evaluated in array mode - Replace throw new IllegalStateException with return ErrorEval.VALUE_INVALID for unexpected argument types (defensive improvement) - Update Javadoc to reflect that array-mode expressions are now supported - Enable previously-disabled testMicrosoftExample3 (SUMPRODUCT with boolean coercion via multiplication now works) - Add regression tests covering: unary minus on out-of-range array, double-negation of numeric array, comparison inside --, -- as first vs second arg, and the original bad.xlsx file from the bug report Add regression tests for the two additional cases discussed in the bug: 1. SUMPRODUCT((range=cellref)*range) - 'even the B2:B9=B12 bit seems to cause issues in POI' comment: comparison of a range against a cell reference, multiplied element-wise by another range. 2. SUMPRODUCT((range="literal")*range) - RouSi's case: =SUMPRODUCT(($N$6:$N$26="镀锌板")*($M$6:$M$26)), string equality comparison of a range against a literal, where the formula cell is outside the referenced range rows (the original OperandResolver.chooseSingleElementFromAreaInternal failure mode). All three patterns now work correctly because Sumproduct implements ArrayMode, causing RelationalOperationEval and TwoOperandNumericOperation (both ArrayFunction) to be evaluated in array mode rather than performing implicit intersection on the range arguments. Co-authored-by: Copilot <[email protected]> Report URL: https://github.com/apache/poi/actions/runs/24606392710 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
