Top Description Fields Constructors Methods
org.apache.poi.ss.formula.functions

public final Class Count

extends Object
implements Function
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.formula.functions.Function
Imports
org.apache.poi.ss.formula.TwoDEval, org.apache.poi.ss.formula.eval.ErrorEval, .MissingArgEval, .NumberEval, .ValueEval, org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate, .CountUtils.I_MatchAreaPredicate

Counts the number of cells that contain numeric data within the list of arguments. Excel Syntax COUNT(value1,value2,...) Value1, value2, ... are 1 to 30 arguments representing the values or ranges to be counted.

Todo

Check this properly matches excel on edge cases like formula cells, error cells etc

Field Summary

Modifier and TypeField and Description
private final CountUtils.I_MatchPredicate
private static final CountUtils.I_MatchPredicate
private static final CountUtils.I_MatchPredicate
subtotalPredicate

matches hidden rows but not subtotals

private static final CountUtils.I_MatchPredicate
subtotalVisibleOnlyPredicate

matches nither hidden rows or subtotals

Constructor Summary

AccessConstructor and Description
public
private
Count(CountUtils.I_MatchPredicate criteriaPredicate)

Method Summary

Modifier and TypeMethod and Description
public ValueEval
evaluate(ValueEval[]
the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.
args
,
int
row index of the cell containing the formula under evaluation
srcCellRow
,
int
column index of the cell containing the formula under evaluation
srcCellCol
)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

public static Count

Returns:

function
subtotalInstance
(boolean
true to include hidden rows in the aggregate, false to skip them
includeHiddenRows
)

Create an instance of Count to use in Subtotal

If there are other subtotals within argument refs (or nested subtotals), these nested subtotals are ignored to avoid double counting.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_predicateback to summary
private final CountUtils.I_MatchPredicate _predicate
defaultPredicateback to summary
private static final CountUtils.I_MatchPredicate defaultPredicate
subtotalPredicateback to summary
private static final CountUtils.I_MatchPredicate subtotalPredicate

matches hidden rows but not subtotals

subtotalVisibleOnlyPredicateback to summary
private static final CountUtils.I_MatchPredicate subtotalVisibleOnlyPredicate

matches nither hidden rows or subtotals

Constructor Detail

Countback to summary
public Count()
Countback to summary
private Count(CountUtils.I_MatchPredicate criteriaPredicate)

Method Detail

evaluateback to summary
public ValueEval evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

Parameters
args:ValueEval[]

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.

srcCellRow:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

row index of the cell containing the formula under evaluation

srcCellCol:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

column index of the cell containing the formula under evaluation

Returns:ValueEval

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

The evaluated result, possibly an ErrorEval, never null

Note

- Excel uses the error code #NUM! instead of IEEE NaN, so when numeric functions evaluate to Double#NaN be sure to translate the result to ErrorEval#NUM_ERROR.

subtotalInstanceback to summary
public static Count subtotalInstance(boolean includeHiddenRows)

Create an instance of Count to use in Subtotal

If there are other subtotals within argument refs (or nested subtotals), these nested subtotals are ignored to avoid double counting.

Parameters
includeHiddenRows:boolean

true to include hidden rows in the aggregate, false to skip them

Returns:Count

function

See Also
Subtotal