Package org.jxls.functions
Class GroupSum<T>
java.lang.Object
org.jxls.functions.GroupSum<T>
- All Implemented Interfaces:
NeedsPublicContext
Group sum
The sum function for calculation a group sum takes two arguments: the collection as JEXL expression (or its name as a String) and the name (as String) of the attribute. The attribute can be a object property or a Map entry. The value type T can be of any type and is implemented by a generic SummarizerBuilder.
Example
Add an instance of this class e.g. with name "G" to your Context.
${G.sum("salary", employees.items)}
Above the 2nd argument is a JEXL expression. The collection name as String is also possible:
${G.sum("salary", "employees.items")}-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetObjectVarName(String objectVarName) voidsetPublicContext(PublicContext context) Returns the sum of the given field of all items.Returns the sum of the given field of all items.
-
Constructor Details
-
GroupSum
-
-
Method Details
-
setPublicContext
- Specified by:
setPublicContextin interfaceNeedsPublicContext
-
sum
Returns the sum of the given field of all items.- Parameters:
fieldName- name of the field of type T to be summed (without the loop var name!)expression- JEXL expression as String, usually name of the Collection, often ends with ".items"- Returns:
- sum of type T
-
sum
Returns the sum of the given field of all items.- Parameters:
fieldName- name of the field of type T to be summed (without the loop var name!)collection- the collection; inside Excel file it's a JEXL expression- Returns:
- sum of type T
-
getObjectVarName
-
setObjectVarName
-
sum
-
sum
-