I'm trying to make a report where each code has x clients. Example
Code 1:
Bruno
Rodrigo
Fernando
Code 2:
Rafael
João
I retrieve these codes from a database, for example:
1 Bruno
1 Rodrigo
1 Fernando
2 Rafael
2 João
As you can see, the codes repeat themselves, so when I generate my report that contains a sub report this whole amount is repeated and the report gets huge.
In short, how could you leave this report as the first example presented?
public void gerarRelatorio(List<PreEmissao> lista, String contrato) throws JRException {
Map<String, Object> parametros = new HashMap<String, Object>();
/**Parametros, essa lista é o DataSource do sub relatório*/
parametros.put("SUBREPORT_DIR", "src/main/resources/Report/Faturamento_subreport.jasper");
parametros.put("lista", lista);
JasperReport jasperReport = JasperCompileManager
.compileReport(getClass().getClassLoader().getResourceAsStream("Report/Faturamento.jrxml"));
/**Essa lista que é passada carrega o DataSorce do relatório principal, dela eu só pego o código*/
JasperPrint print = JasperFillManager.fillReport(jasperReport, parametros,
new JRBeanCollectionDataSource(lista));
JasperExportManager.exportReportToPdfFile(print, "D:/Ouvidoria/Relatorio" + contrato + ".pdf");
System.out.println("Relatório gerado.");
}