Printing a sub report data horizontally

偶尔善良 提交于 2020-01-03 06:19:06

问题


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.


回答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.



来源:https://stackoverflow.com/questions/24241141/printing-a-sub-report-data-horizontally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!