Subreport in ireport

Asked

Viewed 195 times

1

I am 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, example:

1 Bruno
1 Rodrigo
1 Fernando
2 Rafael
2 João

As you can see, the codes are repeated in this way when I repeat my report which contains a sub-report, all that amount is repeated and the report becomes huge.

In short, how could I 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.");

    }
  • Do you want to group by code? Can you include the image of how it is currently and the expected result?

  • The report got very big @Brunocésar, would be basically this, display customers according to the code.

  • When it is generated it displays code 1 and in sub report all data is displayed

  • For example, if I have 5 records with code 1 it generates a sub report for each record that has code 1, the goal is to generate only 1 that contains all clients that have the code 1

  • I solved the problem

1 answer

1


Problem solved, I added one Report Group grouped by code in the report and did not require a sub-report.

inserir a descrição da imagem aqui

  • 1

    Ok. So if that was your answer, and the Report Group feature was your exit, mark your answer as accepted.

  • Yes I will mark as correct, but according to the rules of the site I can only mark my answer as correct after 2 (two) days.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.