javajaspersoft-studio

Multiple Pages in Jasper Report with different table contents


Guys. I've been developing a school management system with java, MySQL and TIBCO Jasper Studio. But I've stuck in a certain point in generating a report. Here is my scenario.

  1. I have two tables called "Student Details" and "Student Results".

  2. In Student Details got "Student ID, Student Name" further Student Results got "Student ID, Subject Name, Grade".

  3. In fact I have successfully managed to populate data in single page in Jasper Studio with Java Code for a single student for showing his/her exam results.
  4. Though, my real requirement is when I give a range of students I want to populate a Jasper Report with multiple pages for given range of students to show their exam results (Grade) in each page as picture.

enter image description here

  1. How ever I managed to populate each page separately for each student. Though results of all students which I select are showing in first page under first student and not showing other students pages.

enter image description here

My method of data populating to report is JRTableModelDataSource for Report page and Report table.


Solution

  • try with following solution,

    short the dataset used by Student ID in SQL query as follows,

    SELECT student_details.student_id, student_details.student_name, student_results.subject, student_results.grade FROM student_details INNER JOIN student_results ON student_details.student_id = student_results.student_id ORDER BY student_details.student_id
    

    create a group based on student_id field and set isStartNewPage property to true,

    field of student_id

    <field name="student_id" class="java.lang.Integer">
        ......
    </field>
    

    group of student_id

    <group name="student_id" isStartNewPage="true">
        <groupExpression><![CDATA[$F{student_id}]]></groupExpression>
    </group>