Class GroupSum<T>

java.lang.Object
org.jxls.functions.GroupSum<T>
All Implemented Interfaces:
NeedsPublicContext

public class GroupSum<T> extends Object implements 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 Details

  • Method Details

    • setPublicContext

      public void setPublicContext(PublicContext context)
      Specified by:
      setPublicContext in interface NeedsPublicContext
    • sum

      public T sum(String fieldName, String expression)
      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

      public T sum(String fieldName, Iterable<Object> collection)
      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

      public String getObjectVarName()
    • setObjectVarName

      public void setObjectVarName(String objectVarName)
    • sum

      public T sum(String fieldName, String expression, String filter)
    • sum

      public T sum(String fieldName, Iterable<Object> collection, String filter)