Jump to content
Changes to the Jaspersoft community edition download ×
  • Uploading Report Units with Subreports


    sameernori

    There are potentially several ways to load reports with a subreport to JasperReports Server. The following recommendation is taken from Section 8.5.4 of the JasperReports Server Pro Ultimate Guide.

    Create the Reports in iReport Designer

    1. Create the subreport; give it a descriptive name (e.g. "subreport.jrxml").
    2. Create the main report; give it a descriptive name (e.g. "mainreport.jrxml").
    3. Drag a Subreport component from the Palette into the main report's Detail band.
    4. Follow the Subreport wizard:
      1. Use an existing report: Browse to locate the file you created in step 1 (e.g. "subreport.jrxml").
      2. Use the same connection used to fill the master report
      3. (Parameters)
      4. Store the directory name in a parameter: $P{SUBREPORT_DIR} + "subreport.jasper"
      5. Finish
    5. Save the main report locally. Do not close the file; you want the main report open. You will use it later.

    Upload the Report Unit to JasperReports Server

    1. If it's not already open, display the Repository Navigator: Window > JasperReports Server Repository.
    2. Browse through the Repository Navigator. Right-click the folder into which you want to upload the report unit.
    3. Click Add > Report Unit.
    4. Enter a descriptive Name and Description for the report unit (the report unit includes the main report, subreport(s), and any other resources).
    5. For the Main JRXML, click "Get source from current opened report".
    6. For Locate Data Source you can select a datasource that's already loaded into the JasperReports Server repository. If you don't yet have a data source, you can click Locally Defined and follow the wizard.
    7. Click Finish. The JRXML validation box appears. Accept all its proposed changes.

    JasperReports Server Converts the Subreport Expression

    Result: the most significant change is that upon loading the report unit in step 12, JasperReports Server stores the subreport as a report resource and converts the Subreport Expression. For example the Subreport expression specified in step 4.4, above when the file was worked locally within iReport: $P{SUBREPORT_DIR} + "subreport.jasper" becomes "repo:subreport.jrxml" when uploaded as part of a report unit to the shared JasperReports Server repository.

    Suggested Reading

    To learn the basics of creating subreports, refer to Subreports!. More information is available in Chapter 11 of the iReport Ultimate Guide. You can purchase the Jaspersoft Ultimate Guides at http://www.jaspersoft.com/ultimate-guides.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...