Как показать содержимое списка в JasperReports - PullRequest
1 голос
/ 09 февраля 2012

У меня есть Коллекция типа Список , которую я хочу передать в отчет, используя JasperReports и iReport на NetBeans , но мне не удается отобразить содержимое списка в отчете.Я не знаю, как отобразить данные в разделе Подробности jrxml.Какой параметр я должен использовать?В списке есть объекты типа Proveedor (поставщик на испанском языке) и переменные, такие как имя, код и т. Д.Вот код метода, который вызывает JasperReports :

public void generateReport(List<Proveedor> aList){
    String reportName = System.getProperty("user.dir") + "\\src\\reports\\lista-proveedores.jrxml";
    JRBeanCollectionDataSource dataSource;
    JasperReport jasperReport;
    JasperPrint jasperPrint;

    try{
        //1-I fill the dataSource with the Collection
        dataSource = new JRBeanCollectionDataSource(aList);

        //2-Compile the XML
        jasperReport = JasperCompileManager.compileReport(reportName);

        //3-Fill the report with the datasource
        jasperPrint = JasperFillManager.fillReport(jasperReport, null, dataSource);

        //4-Export to PDF and save to disk
        JasperExportManager.exportReportToPdfFile(jasperPrint, "Proveedores.pdf");

        System.out.println("Finished!");

    }catch (Exception e){
        System.out.println(e);
        //e.printStackTrace();
    }
}
...