本文介绍了使用适用于JasperReports的iReport工具创建子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于 struts 的应用程序。我想创建一个Jasper报告,其中包含 Paper 对象的问题和答案。显然我有一个 Paper 列表,其中包含part属性,每个 Paper 对象内部有一个 问题列表 。此外,每个 问题 都有一个回复列表。

I'm working on a struts based application. I want to create a Jasper report containing questions and responses for a Paper Object. Clearly I have a List of Paper objects containing part attribute and each Paper object internally has a List of Questions. Also each Question has a List of Responses.

我可以创建主要报告使用Paper对象显示不同的部件名称。但我想显示与部件相关的问题以及与每个问题相关的响应。

I could create the main report with Paper object which displays different part names. But I want to display the questions associated with the part and responses associated with each question.

我的模型类将是:

// Paper
public class Paper {

    public String partName;
    public List<Question> questions;
}

// Question
public class Question {

    public String question;
    public List<Answer> answers;
}

// Answer
public class Answer {

    public String answer;
}

我知道我必须在 iReport中使用子报告。当我这样做时,数据源表达式的编译失败 new JRBeanCollectionDataSource($ F {questions})

I know I have to use subreport in iReport. When i did so the compilation fails for the data source expression new JRBeanCollectionDataSource($F{questions})

推荐答案

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($ F {questions})

new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{questions})

这篇关于使用适用于JasperReports的iReport工具创建子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:18