When a collection expression such as those used in implicit collections processing appears in a sheet name, implicit sheet cloning is the result.
If JETT detects that an Expression on a sheet name contains operations on a Collection, then it clones the sheet, resulting in one cloned sheet per collection item.
In this example, "emps" is a List of Employees. The List doesn't have the properties "lastName", "firstName", "salary", and "manager" (methods getLastName(), getFirstName(), getSalary(), and getManager()). The implicit sheet cloning gets these properties from each item of the "employees" list. The sheet name here, ${emps.fullName}, contains the collection expression. One sheet is created for each of the 4 employees.
Employee | ${emps.lastName}, ${emps.firstName} | ||
Salary | ${emps.salary} | ||
Manager | <jt:if test="${emps.getManager() != null}" then="${emps.manager.lastName}, ${emps.manager.firstName}"/> | ||
${emps.fullName} |
...gets transformed into the four sheets...
Employee | Stack, Robert | ||
Salary | $1000.00 | ||
Manager | |||
Robert Stack | Suzie Queue | Elmer Fudd | Bugs Bunny |
Employee | Queue, Suzie | ||
Salary | $900.00 | ||
Manager | Stack, Robert | ||
Robert Stack | Suzie Queue | Elmer Fudd | Bugs Bunny |
Employee | Fudd, Elmer | ||
Salary | $800.00 | ||
Manager | Stack, Robert | ||
Robert Stack | Suzie Queue | Elmer Fudd | Bugs Bunny |
Employee | Bunny, Bugs | ||
Salary | $1500.00 | ||
Manager | |||
Robert Stack | Suzie Queue | Elmer Fudd | Bugs Bunny |
To change the default behavior of implicit sheet cloning, include metadata at the end of an Expression that contains a reference to a Collection. Metadata may influence the affected sheet, by limiting the number of collection items and/or introducing status variables. The metadata key "?@" cannot be used in implicit sheet cloning, because Excel prevents the "?" character from being used in sheet names. Instead, append the string "$@" plus key/value pairs to the end of the Expression, separated by semicolons.
Most metadata keys that exist in implicit collections processing don't make sense in this context, but a few do. The keys that do apply here are abbreviated to one character, to maximize the space utilized by Excel's 31-character limit on sheet names.
Once JETT has determined that it will perform implicit sheet cloning, it will scan the entire sheet for any references to any Collections in any Expression. Then, it will clone the sheet as many times as necessary. Each sheet receives the appropriate collection item exposed in the beans map for transformation.