Bug 45289

Summary: [PATCH]Small improvement for HSSF Countif function
Product: POI Reporter: dnapoletano <domenico.napoletano>
Component: HSSFAssignee: POI Developers List <dev>
Severity: enhancement    
Priority: P2    
Version: 3.0-dev   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

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.