Bug 45289 - [PATCH]Small improvement for HSSF Countif function
Summary: [PATCH]Small improvement for HSSF Countif function
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-06-26 09:07 UTC by dnapoletano
Modified: 2008-07-11 01:03 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description dnapoletano 2008-06-26 09:07:27 UTC
The current COUNTIF funztion implementation in HSSF can handle espression like

COUNTIF(A1:A5; "12")

COUNTIF(A1:A5; "right")

but not analogous ones like

COUNTIF(A1:A5; "=12")

COUNTIF(A1:A5; "=right")

A simple patch could consist of small editing of createGeneralMatchPredicate method:

1) replace the first statement

String value = stringEval.getStringValue();


String value = stringEval.getStringValue().replaceAll("^=", "");

2) comment out the

case '=':

statement (preserving the throw statement right next)
Comment 1 Nick Burch 2008-06-28 11:59:55 UTC
This looks like an OK fix to me.

Josh - as our current formula guru, does it make sense to you too?
Comment 2 Josh Micich 2008-07-11 01:03:40 UTC
Fixed in svn r675853.

Added support for all operators (=, <>, <, <=, >, >=), also wildcard criteria.
Fixed up POI to follow COUNTIF's funny type conversion rules.

Junits added.