![](/img/trans.png)
[英]How to get the current bean when iterating over a JRBeanCollectionDataSource in Jasper Reports?
[英]JRBeanCollectionDataSource in jasper how to use
try {
//Connecting to the MySQL database
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital", "root" ,"root");
String report="C:\\Users\\DELL\\report10.jrxml";
JasperReport jasperreport=JasperCompileManager.compileReport(report);
patientDB DataBeanList = new patientDB();
ArrayList<patientBean> dataList = DataBeanList.getDataBeanList();
JRBeanCollectionDataSource beanColDataSource =
new JRBeanCollectionDataSource(dataList);
Map<String,Object> parameters = new HashMap<String,Object>();
JasperPrint jp=JasperFillManager.fillReport(jasperreport, parameters,beanColDataSource);
JasperViewer.viewReport(jp);
}
catch(Exception e)
{
out.println(e);
}
我是刚在碧玉报告中尝试从bean类中获取价值的新手,但是什么也没有发生,我为此花了最后7天的时间
请澄清,
您遇到什么错误?
DataBeanList.getDataBeanList()返回带有值的对象吗?
Db连接配置是否正确?
jrxml的路径正确吗?(我认为您不需要在路径中使用双斜杠)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.