如何在JasperReports中显示列表的内容
我有一个 List 类型的 Collection,我想将其传递到使用 JasperReports 和 iReport 的报表 < em>NetBeans,但我无法在报告上显示列表的内容。
我不知道如何显示 jrxml 的 详细信息 部分中的数据。我应该使用什么参数?
该列表包含 Proveedor
(西班牙语为 Provider)类型的对象,并包含名称、代码等变量。
以下是调用 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();
}
}
I have a Collection of type List that I want to pass it to a report using JasperReports and iReport on NetBeans, but I can't manage to show the content of the list on the Report.
I don't know how to show the data in the Details section of the jrxml. What parameter should I use?
The list has Objects of type Proveedor
(Provider in Spanish) and has variables like name, code, etc.
Here is the code of the method who call to 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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论