JXLS 公式不按指定字段对输出进行分组

JXLS Formula not grouping output by specified field

我正在创建报告,我需要将我的数据结构输出到 excel 电子表格。为此,我使用的是 JXLS,但在创建 jx 公式以正确输出数据时遇到了问题。

我有一个人的列表:

 List<Person> people = new ArrayList<Person>();

在我的 Person class 中,它具有以下属性:

String name;
String age;
List<Pet> listOfPets;

对于我使用的一些虚假数据:

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);

我希望它按年龄分组显示在 Excel 中。例如:

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

我目前的情况是这样的:

<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>   

上面确实输出了正确的数据,但它没有按年龄分组...它显示为大量重复年龄的列表?我怎样才能将所有未满特定年龄的人分组?

您应该使用 groupBy="age" 而不是 groupBy="${person.age}" 作为在 Jxls 1.x documentation.

中解释

然而,战略建议是使用 Jxls-2 and its Each-command 代替不受支持的旧版 Jxls-1 进行分组。