如何在JasperReports中显示List的内容

时间:2012-02-09 15:04:21

标签: java jasper-reports ireport

我有 List 类型的集合,我希望使用 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();
    }
}

0 个答案:

没有答案