// Create a new workbook Workbook workbook = new Workbook(); //Load template file from resource InputStream templateFile = this.getResourceStream("xlsx/Template_EmployeeAbsenceSchedule.xlsx"); workbook.open(templateFile); //Here in the demo, we use a mock class to generate instance of java.sql.ResultSet. //User who use template in product, must get instance of java.sql.ResultSet from the //related database connection. MyTableDataSource datasource = new MyTableDataSource(this.getResourceStream("data/employee absence schedule.csv")); //Init template global settings workbook.getNames().add("TemplateOptions.KeepLineSize", "true"); //Add data source workbook.addDataSource("ds", datasource); //Invoke to process the template workbook.processTemplate(); // Save to an excel file workbook.save("EmployeeAbsenceSchedule.xlsx");