Hello, so far we created several stand-alone one page reports. All independent from each other. Now we want to assemble them together in one master report. Being still quite new to Jasper I already figured out:
- I can assemble 2 reports by putting one as a subreport in the title and another in the summary section - but we got many more, so no soulation.
- If we put a sequence of sub-reports into the title section, they either overwrite each other (as x=0 and y=0) or you get an error because the end of page is reached after the first subreport => no solution
- If (in 2.) we put a
in-between 2 sub-reports, they still overwrite and we can another empty page => no solution We also cannot use the "detail" section: Because the datasource of the master report is empty, it will never display anything If can't use the "noData" section because it has the same problems as in 2.
<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0 --> <!-- 2015-02-04T19:21:41 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_Landscape" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a37e5125-a809-4647-b6bf-703c70e34714"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="TDBSYNCPROD.xml"/> <background> <band splitType="Stretch"/> </background> <noData> <band height="595" splitType="Stretch"> <subreport runToBottom="true"> <reportElement key="1" mode="Opaque" x="0" y="0" width="803" height="554" isPrintInFirstWholeBand="true" backcolor="rgba(255, 255, 255, 0.0)" uuid="28128e81-8e7a-4fbb-b93f-3a7e83c8ab47"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["SalesBookingsHistory.jasper"]]></subreportExpression> </subreport> <subreport runToBottom="true"> <reportElement key="2" positionType="Float" mode="Opaque" x="0" y="0" width="803" height="554" isPrintInFirstWholeBand="true" backcolor="rgba(255, 255, 255, 0.0)" uuid="28128e81-8e7a-4fbb-b93f-3a7e83c8ab47"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["DGR_Report_absolut.jasper"]]></subreportExpression> </subreport> </band> </noData> </jasperReport>
2 Answers:
Hi
I am assuming you don't need parameters, so in your main report set a connection to the database as normal and pass this to each subreport as the connection.
Use this query "SELECT 1 AS dummy" for your master report.
Then create a detail band for each subreport.
I don't know if it is relevant but in the one I made I fetch a value from each subreport to the main but i dont think this is needed.
Many thanks, Peter,
you were right, I presently don't have to pass parameters nor I have to return values from the subreports.
So the solution below works works for me (for my Oracle DB) :
<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 6.0.1.final using JasperReports Library version 6.0.0 --> <!-- 2015-02-05T14:42:34 --> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="01_MasterDailyReport" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="a37e5125-a809-4647-b6bf-703c70e34714"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="TDBSYNCPROD.xml"/> <queryString language="SQL"> <![CDATA[SELECT 1 AS DUMMY from DUAL]]> </queryString> <background> <band splitType="Stretch"/> </background> <detail> <band height="595" splitType="Stretch"> <subreport runToBottom="true"> <reportElement key="1" mode="Opaque" x="0" y="0" width="803" height="554" isPrintInFirstWholeBand="true" backcolor="rgba(255, 255, 255, 0.0)" uuid="28128e81-8e7a-4fbb-b93f-3a7e83c8ab47"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["SalesBookingsHistory.jasper"]]></subreportExpression> </subreport> </band> <band height="595" splitType="Stretch"> <subreport runToBottom="true"> <reportElement key="2" positionType="Float" mode="Opaque" x="0" y="0" width="803" height="554" isPrintInFirstWholeBand="true" backcolor="rgba(255, 255, 255, 0.0)" uuid="28128e81-8e7a-4fbb-b93f-3a7e83c8ab47"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["DGR_Report_absolut.jasper"]]></subreportExpression> </subreport> </band> </detail> </jasperReport>