iReport工具的使用(二)

JavaBean作为数据源开发报表

1、 创建DataBean,报表数据的每一个字段将对应该DataDean对象的一个属性

package direction.shoufei.report.groupyearfee.data;

public class CenterYearFee {
    
private String centerId;
    
private String centerName;
    
private String queryYear;
    
private double summary;
    
private double preYearsummary;
    
private double preYearRate;
    
private double month1Fee;
    
private double month2Fee;
    
private double month3Fee;
    ...
    
    
public String getCenterId() {
        
return centerId;
    }
    
public void setCenterId(String centerId) {
        
this.centerId = centerId;
    }
    
public String getCenterName() {
        
return centerName;
    }
    
public void setCenterName(String centerName) {
        
this.centerName = centerName;
    }
    
public String getQueryYear() {
        
return queryYear;
    }
    
public void setQueryYear(String queryYear) {
        
this.queryYear = queryYear;
    }
    
public double getSummary() {
        
return summary;
    }
    
public void setSummary(double summary) {
        
this.summary = month1Fee + month2Fee + month3Fee + month4Fee
                
+ month5Fee + month6Fee + month7Fee + month8Fee + month9Fee
                
+ month10Fee + month11Fee + month12Fee;
    }  
    
public double getPreYearsummary() {
        
return preYearsummary;
    }
    
public void setPreYearsummary(double preYearsummary) {
        
this.preYearsummary = preYearsummary;
    }
    
public double getPreYearRate() {
        
return preYearRate;
    }
    
public void setPreYearRate(double preYearRate) {
        
this.preYearRate = preYearRate;
    }
    
public double getMonth1Fee() {
        
return month1Fee;
    }
    
public void setMonth1Fee(double month1Fee) {
        
this.month1Fee = month1Fee;
    }
    
public double getMonth2Fee() {
        
return month2Fee;
    }
    
public void setMonth2Fee(double month2Fee) {
        
this.month2Fee = month2Fee;
    }
    
public double getMonth3Fee() {
        
return month3Fee;
    }
    
public void setMonth3Fee(double month3Fee) {
        
this.month3Fee = month3Fee;
    }
    ...
}

 

2、 设置类路径


3、 iReport报表设计界面添加DataBean源字段

 

3、 用拖拽的方式将字段添加到Band(即DetailcolumnHeadercolumnFooter……),并且格式化报表

 

截止这里,报表的设计已完成。

下一步需要将报表展现的数据封装成一个List<DataBean>的对象。 
posted on 2011-03-21 11:13  北漂浪子  阅读(1774)  评论(0编辑  收藏  举报