You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/09/20 17:02:56 UTC
[PR] [bug-69853] COUNTIF "<>" counts every non-blank cell, whatever its type [poi]
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
Re: [PR] [bug-69853] COUNTIF "<>" counts every non-blank cell, whatever its type [poi]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1327:
URL: https://github.com/apache/poi/pull/1327
--
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: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org