This section contains several examples demonstrating how to export collections with jXLS. In all samples we assume there are two Java beans of type Department and Employee
This sample demonstrates how to export a collection of employees. Source code is as following
Collection staff = new HashSet();
staff.add(new Employee("Derek", 35, 3000, 0.30));
staff.add(new Employee("Elsa", 28, 1500, 0.15));
staff.add(new Employee("Oleg", 32, 2300, 0.25));
staff.add(new Employee("Neil", 34, 2500, 0.00));
staff.add(new Employee("Maria", 34, 1700, 0.15));
staff.add(new Employee("John", 35, 2800, 0.20));
Map beans = new HashMap();
beans.put("employee", staff);
XLSTransformer transformer = new XLSTransformer();
transformer.transformXLS(templateFileName, beans, destFileName);
Template file screenshot

You can also download Excel version employees.xls
Output file looks like

Excel file employees_output.xls
This sample demonstrates how to export Department bean. Source code snippet
Department department = new Department("IT");
//... initialization is skipped here
Map beans = new HashMap();
beans.put("department", department);
XLSTransformer transformer = new XLSTransformer();
// set grouping of rows for "department.staff" collection
transformer.groupCollection("department.staff");
transformer.transformXLS(templateFileName, beans, destFileName);
Here is a template file screenshot

Excel version is here department.xls
Using this template we'll get an output like

Excel is here department_output.xls
This sample demonstrates how to export collection with several rows per every collection item. Source code snippet
Department department = new Department("IT");
//... initialization is skipped here
Map beans = new HashMap();
beans.put("department", department);
XLSTransformer transformer = new XLSTransformer();
transformer.transformXLS(templateFileName, beans, destFileName);
Here is a template file screenshot

See excel file for details multiplelistrows.xls
Using this template we'll get an output like

Excel is here multiplelistrows_output.xls
This sample demonstrates how to export collections nested in other collections. We export collection of departments and every department contain staff collection. Source code snippet
// create a list of Departments
List departments = new ArrayList();
//... initialization
Map beans = new HashMap();
beans.put("departments", departments);
XLSTransformer transformer = new XLSTransformer();
transformer.transformXLS(templateFileName, beans, destFileName);
Template is

See also xls file grouping.xls
Output is

Excel is here grouping_output.xls