将一组JavaBean作为数据源传递给Jasper,如何在ireports中进行设计

将一组JavaBean作为数据源传递给Jasper,如何在ireports中进行设计,java,jasper-reports,ireport,Java,Jasper Reports,Ireport,我需要设计一个报告,显示一个集合(比如列表)中的数据。此列表包含多个POJO POJO由应用程序的数据访问层填充。如何在iReports中为此要求设计报表模板?用于您的报表。好!找到了答案。步骤如下 编译bean类并创建一个JAR文件。这需要有完整的软件包 将此jar添加到ireports中的LIB文件夹 创建具有填充集合的createBeanCollection方法的工厂/包装器类 使用此类的顶级包作为ireports中的类路径 使用该类作为方法的JavaBean数据源 完成所有这些之后,使用

我需要设计一个报告,显示一个集合(比如列表)中的数据。此列表包含多个POJO


POJO由应用程序的数据访问层填充。如何在iReports中为此要求设计报表模板?

用于您的报表。

好!找到了答案。步骤如下

  • 编译bean类并创建一个JAR文件。这需要有完整的软件包
  • 将此jar添加到ireports中的LIB文件夹
  • 创建具有填充集合的createBeanCollection方法的工厂/包装器类
  • 使用此类的顶级包作为ireports中的类路径
  • 使用该类作为方法的JavaBean数据源
  • 完成所有这些之后,使用新的数据源和报告查询创建一个报告,在JavaBean上提供FQN并添加所需的字段

    BankDetailsList list = new BankDetailsList();       
    ArrayList<BankDetails> lst = list.getDataBeanList();        
    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(lst);
    
    帐户POJO:

    public class Account {
    
        public int account_id;
        public String account_name;
    
        Account(int acc_id, String acc_name){
            this.account_id = acc_id;
            this.account_name = acc_name;
        }
    
        public int getAccount_id() {
            return account_id;
        }
    
        public void setAccount_id(int account_id) {
            this.account_id = account_id;
        }
    
        public String getAccount_name() {
            return account_name;
        }
    
        public void setAccount_name(String account_name) {
            this.account_name = account_name;
        }
    }
    

    我不应该使用JavaBean集合数据源吗?对于一个bean集合,这是要使用的:)您能详细说明步骤3吗
    public class Account {
    
        public int account_id;
        public String account_name;
    
        Account(int acc_id, String acc_name){
            this.account_id = acc_id;
            this.account_name = acc_name;
        }
    
        public int getAccount_id() {
            return account_id;
        }
    
        public void setAccount_id(int account_id) {
            this.account_id = account_id;
        }
    
        public String getAccount_name() {
            return account_name;
        }
    
        public void setAccount_name(String account_name) {
            this.account_name = account_name;
        }
    }