AbstractPoiXlsxReportGenerator implements ReportGenerator { @Override public void generateReport(final ReportDescriptor descriptor, final Map<String, Object> parameters, final Object data, final String lang, final OutputStream outputStream) { if (data == null || data instanceof Collection && ((Collection) data).isEmpty()) { LOG.debug("No data, no report will be generated"); return; } try { final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet = workbook.createSheet(descriptor.getReportId()); final XSSFCellStyle headerStyle = workbook.createCellStyle(); final XSSFFont font = workbook.createFont(); font.setBold(true); headerStyle.setFont(font); int rowNum = 0; for (Object dataLine : (Collection) data) { final Object[] line = (Object[]) dataLine; final Row row = sheet.createRow(rowNum++); int colNum = 0; for (Object field : line) { final Cell cell = row.createCell(colNum++); if (rowNum == 1) { cell.setCellStyle(headerStyle); } if (field instanceof String) { cell.setCellValue((String) field); } else if (field instanceof Number) { cell.setCellValue(((Number) field).doubleValue()); } else { cell.setCellValue(""); } } } workbook.write(outputStream); workbook.close(); } catch (Exception exp) { LOG.error("Unable to generate report for " + descriptor + " in " + lang, exp); } }  @Override boolean supports(final ReportDescriptor reportDescriptor); @Override void generateReport(final ReportDescriptor descriptor,
                               final Map<String, Object> parameters,
                               final Object data,
                               final String lang,
                               final OutputStream outputStream);  }
@Test public void testGenerateXlsxReport() throws Exception { final AbstractPoiXlsxReportGenerator generator = new AbstractPoiXlsxReportGenerator() { }; final ReportDescriptorXLSX availableStock = new ReportDescriptorXLSX(); availableStock.setReportId("available-stock"); availableStock.setVisible(true); final ByteArrayOutputStream baosAvailableStock = new ByteArrayOutputStream(); generator.generateReport(availableStock, new HashMap<String, Object>() {{ put("p1", "v1"); }}, generateData(), "en", baosAvailableStock); assertTrue(baosAvailableStock.toByteArray().length > 0); try(FileOutputStream fos = new FileOutputStream("target/test-xlsx-report.xlsx")) { fos.write(baosAvailableStock.toByteArray()); } }