Jasper reports 表工具,用于显示较少/较少的数据库记录

Jasper reports 表工具,用于显示较少/较少的数据库记录,jasper-reports,Jasper Reports,我用的是JasperReports。在这种情况下,我使用表和JavaBean数据源。但是,当我将数据从java类发送到jrxml表时,它显示的记录少了一条。例如,如果我的java类中有四条记录,但当将其导出到报告时,它只显示三条记录。 数据Bean如下所示: 公共类数据库实现了可序列化{ private static final long serialVersionUID = 1L; private String description; private String location; pr

我用的是JasperReports。在这种情况下,我使用表和JavaBean数据源。但是,当我将数据从java类发送到jrxml表时,它显示的记录少了一条。例如,如果我的java类中有四条记录,但当将其导出到报告时,它只显示三条记录。 数据Bean如下所示: 公共类数据库实现了可序列化{

private static final long serialVersionUID = 1L;

private String description;
private String location;
private Date date;
private String type;
private String state;
private String comments;

/**
 * Parameterized constructor.
 * 
 * @param description
 *            description of alarm.
 * @param location
 *            location of alarm.
 * @param date
 *            date of alarm.
 * @param type
 *            type of alarm.
 * @param state
 *            state of alarm.
 * @param note
 *            note/comments of alarm.
 */
public DataBean(String description, String location, Date date,
        String type, String state, String note) {
    this.description = description;
    this.location = location;
    this.date = date;
    this.type = type;
    this.state = state;
    this.comments = note;
}

/**
 * Getter method to get the
 * 
 * @return location
 */
public String getLocation() {
    return location;
}

/**
 * Setter method to set the location.
 * 
 * @param location
 */
public void setLocation(String location) {
    this.location = location;
}

/**
 * Getter method to get the date.
 * 
 * @return date
 */
public Date getDate() {
    return date;
}

/**
 * Setter method to set the date.
 * 
 * @param date
 */
public void setDate(Date date) {
    this.date = date;
}

/**
 * Getter method to get the type.
 * 
 * @return type
 */
public String getType() {
    return type;
}

/**
 * Setter method to set the type.
 * 
 * @param type
 */
public void setType(String type) {
    this.type = type;
}

/**
 * Getter method to get the state.
 * 
 * @return state
 */
public String getState() {
    return state;
}

/**
 * Setter method to set the state.
 * 
 * @param state
 */
public void setState(String state) {
    this.state = state;
}

/**
 * Getter method to get the description.
 * 
 * @return description
 */
public String getDescription() {
    return description;
}

/**
 * Setter method to set the description.
 * 
 * @param description
 */
public void setDescription(String description) {
    this.description = description;
}

/**
 * Getter method to get the comments.
 * 
 * @return comments
 */
public String getComments() {
    return comments;
}

/**
 * Setter method to set the comments.
 * 
 * @param comments
 */
public void setComments(String comments) {
    this.comments = comments;
}
}

我的主要课程如下: List beanCollection=new ArrayList()

for(int i=0;i<2;i++){
DataBean=新数据区(“报警描述”、“位置”,
新日期(),“EventScheduleStopped-12”,“AlarmAcknowledged”,
“这是警报的测试注释。”);
添加(bean);
}
System.out.println(beanCollection.size());
List filterCollection=new ArrayList();
FilterBean FilterBean=新的FilterBean(“过去7天”,“任何类型”,
“公开”);
filterCollection.add(filterBean);
InputStream InputStream=ReportManagementController.class
.getResourceAsStream(“/report.jrxml”);
JRBeanCollectionDataSource beanColDataSource=新的JRBeanCollectionDataSource(
beanCollection);
JRBeanCollectionDataSource过滤器BeanCollectionDataSource=新JRBeanCollectionDataSource(
过滤收集);
映射参数=新的HashMap();
parameters.put(显示注释,true);
parameters.put(显示过滤器,false);
参数。放置(“徽标”,
ReportManagementController.class.getResource(新图像名称)
.getPath());
parameters.put(“TableDataSource”,beanColDataSource);
参数put(“filterDataSource”,filterBeanCollectionDataSource);
JasperDesign JasperDesign=JRXmlLoader.load(inputStream);
JasperReport JasperReport=JasperCompileManager
.compileReport(jasperDesign);
JasperPrint JasperPrint=JasperFillManager.fillReport(jasperReport,
参数,beanColDataSource);
JasperViewer.viewReport(jasperPrint);
我的jrxml(只显示jrxml的部分内容,因为它太大)如下所示:

参数name=“TableDataSource”class=“net.sf.jasperreports.engine.JRDataSource”/

数据源表达式>![CDATA[$P{TableDataSource}]>dataSourceExpression> 谁来帮帮我。

这是JR的已知功能(或bug?)

要解决此问题,请将集合(不是JRDataSource!)作为参数传递,并在表的dataSource中使用此集合

例如:

parameters.put("beanCollection", beanCollection);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
            parameters, new JREmptyDataSource());
在jrxml中,将参数“beanCollection”定义为java.util.Collection

并将jrxml中表的数据源表达式定义为

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{beanCollection})
这是JR的已知特性(或bug?)

要解决此问题,请将集合(不是JRDataSource!)作为参数传递,并在表的dataSource中使用此集合

例如:

parameters.put("beanCollection", beanCollection);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
            parameters, new JREmptyDataSource());
在jrxml中,将参数“beanCollection”定义为java.util.Collection

并将jrxml中表的数据源表达式定义为

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{beanCollection})

您的问题不明确您的问题不明确Yuarin或case传递新的JREPTYDATASOURCE()作为fillReport的最后一个参数可能会解决问题。可能是…在YOUR情况下,将新JREPTYDATASOURCE()作为fillReport的最后一个参数传递可能会解决问题。可能是。。。