pjfanning opened a new pull request, #1327: URL: https://github.com/apache/poi/pull/1327
Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=69853 `COUNTIF(A1:A2,"<>")` over a number and a text gave 1 instead of 2. The reporter checked Excel and LibreOffice; Microsoft's COUNTIF documentation itself lists `COUNTIF(range,"<>")` as the way to count non-empty cells. ### Cause `Countif.StringMatcher.matches` returns `false` for any cell that is not text, whatever the operator. That is right for `=`/plain criteria (a number never equals a text — `"4*7"` must not match 4567) but wrong for `<>`: a number, boolean or error is *not equal* to the empty text, so `"<>"` has to count it, and so does `"<>abc"`. The other matchers had the same gap in places: `NumberMatcher` already handled `<>` for text and blanks (bug 51498) but not booleans/errors, `BooleanMatcher` returned false for text and errors, `ErrorMatcher` for everything that is not an error. `<>` now means "not equal" consistently: a cell of another type matches under `<>` and only under `<>`; `=`, plain and ordering criteria are unchanged. Blank handling is unchanged (`"<>"` excludes blanks, `"<>abc"` includes them). ### Tests (`TestCountFuncs`) - `testNotEqualCountsValuesOfOtherTypes_Bug69853`: predicate-level, for `"<>"`, `"<>abc"`, `"<>5"`, `"<>TRUE"`, `"<>#N/A"` against every value type, plus the equality cases staying false. - `testCountifNotEmptyInWorkbook_Bug69853`: the reporter's case, and COUNTIF/COUNTIFS/SUMIF/SUMIFS over a column with a number, text, boolean, error and blank. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
