Printing a sub report data horizontally
Asked Answered
B

1

0

I have a requirement where in I need to print the data in my sub report in horizontal order rather than vertical.

However the master data is still to be presented in vertical order.

The report presentation is something like this below where the Subject column would grow horizontally for each record.

I have tried keeping the Subject records as a subreport to the main report but it does not get printed horizontally.

TeacherId         TeacherName        Subject1      Subject2     Subject3

1                 Tom                Physics        Chem          Bio
2                 Sofie              Eng            History       Geography
3                 Monique            Eng            Chem          Physics

Checked a few existing answers but no clue.

Any help would be thankful.

Buckden answered 16/6, 2014 at 10:2 Comment(0)
B
1

I would share the changes done to achieve the above output if it helps anyone:

  1. Create the report to be embedded as a subreport as an independent report.
  2. Change the printOrder to "horizontal" and Columns: n (where n can be any value greater than 1)
  3. Save the jrxml file.
  4. In the master report add the sub report element. while adding chose the option "just add the subreport element".
  5. Go to the Properties tab of the subreport element do the following changes as below:

    Subreport Expression: $P{SUBREPORT_DIR}+"SubReportfileName.jasper"
    

    DataSourceExpression: new net.sf.jasperreportsengine.data.JRBeanCollectionDatasource($F{subjects})

, here subjects is the field name for the BO Subjects present as an association in Teacher BO.

Buckden answered 18/6, 2014 at 7:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.