Q:

JXLS Formula not grouping output by specified field

I am creating a report and I need to output my data structure to an excel spreadsheet. For this, I am using JXLS but am having trouble with creating the jx formula to output the data properly.
I have a list of type person:
 List<Person> people = new ArrayList<Person>();

Within my Person class it has the following attributes:
String name;
String age;
List<Pet> listOfPets;

For some fake data I am using:
petList1.add("Dog");
petList1.add("Cat");
people.add(new Person("Joseph", "18", petList1);

petList2.add("Dog");
petList2.add("Fish");
people.add(new Person("Tommy", "18", petList2);

petList3.add("Bird");
petList3.add("Dog");
people.add(new Person("Sally", "19", petList3);

I want this to showup in Excel as grouped by age. So for example:
Age 18:
      Name: Joseph
      Age: 18
      Pets: Dog, Cat
      ----------------
      Name: Tommy
      Age: 18
      Pets: Dog, Fish

Age 19:
      Name: Sally
      Age: 19
      Pets: Bird, Dog

What I have so far is this:
<jx:forEach items="${personsList}" var="person"> groupBy="${person.age}"                
Name :   ${person.name}
Age  :   ${person.age}          
<jx:forEach items="${person.listOfPets}" var="pets">                
Pets :  ${pets.type},
</jx:forEach>               
</jx:forEach>   

The above does output the correct data but it isn't grouping it by age... It's showing up as a large list of repeating ages? How can I get this to group all under specific age?

A:

You should use groupBy="age" instead of groupBy="${person.age}" as explained in Jxls 1.x documentation.
However the strategic recommendation is to use Jxls-2 and its Each-command to do the grouping instead of the legacy Jxls-1 which is unsupported.

