Jasper reports 如何填充此JRDataSource?

Jasper reports 如何填充此JRDataSource?,jasper-reports,Jasper Reports,我想使用jasper report使用JRDataSource创建pdf文档。实际上,我有一个bean对象,该对象包含另一个bean对象的列表和一个字符串值,内部bean对象有两个字符串变量。现在我不知道如何在jrxml文档中映射这三个变量来填充pdf文档中的值。 有人能帮我解决这个问题吗。如果你能提供一些代码片段。从集合数据源创建JasperPrint对象的代码片段 JasperPrint jp = new JasperPrint(); String reportPath = "/HD/jas

我想使用jasper report使用JRDataSource创建pdf文档。实际上,我有一个bean对象,该对象包含另一个bean对象的列表和一个字符串值,内部bean对象有两个字符串变量。现在我不知道如何在jrxml文档中映射这三个变量来填充pdf文档中的值。
有人能帮我解决这个问题吗。如果你能提供一些代码片段。

从集合数据源创建JasperPrint对象的代码片段

JasperPrint jp = new JasperPrint();
String reportPath = "/HD/jasper/mypath/myfile.jasper";

Map paramsMap = new HashMap();  //put whatever parameters you want to pass to report

//JR data source, populate with your collection
JRDataSource reportSource = new JRBeanCollectionDataSource( reportCollection );

jp = JasperFillManager.fillReport( reportPath, paramsMap, reportSource);

//Here you can use the PDF generator to make a PDF file out of the jp object. Then forward it to client

从集合数据源创建JasperPrint对象的代码段

JasperPrint jp = new JasperPrint();
String reportPath = "/HD/jasper/mypath/myfile.jasper";

Map paramsMap = new HashMap();  //put whatever parameters you want to pass to report

//JR data source, populate with your collection
JRDataSource reportSource = new JRBeanCollectionDataSource( reportCollection );

jp = JasperFillManager.fillReport( reportPath, paramsMap, reportSource);

//Here you can use the PDF generator to make a PDF file out of the jp object. Then forward it to client

我不明白。reportCollection在哪里初始化?@StefanosKargas这是一个非常古老的问题和答案。如果你有任何问题,请发一个新问题。我不明白。reportCollection在哪里初始化?@StefanosKargas这是一个非常古老的问题和答案。如果您有任何问题,请发布新问题。