I have a report containing a table with dynamic content on the left side and a frame containing static fixed size text on the right side:
Below you find the jrxml source (I removed the title and three columns of the table to reduce the size):
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-08-10T11:19:14 -->
<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="WaterlevelForecastReport" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryNewPage="true" resourceBundle="messages" whenResourceMissingType="Empty" uuid="3cf70749-5058-4a53-ad3e-091553a6ed3e">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF" hTextAlign="Center" vTextAlign="Middle" isBlankWhenNull="true" fontName="Arial" fontSize="8" isBold="false">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="DataStyle" hTextAlign="Center" isBlankWhenNull="true" fontName="Arial" fontSize="8" isBold="false"/>
<subDataset name="WaterLevelForecastDataSet" uuid="01de13e9-d88f-4fef-b1bf-4de28bf02e6a">
<parameter name="waterlevelForecastData" class="com.example.reporting.WaterlevelForecastReportService.WaterlevelForecastData">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<field name="waterLevel" class="com.example.WaterLevelForecast">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
</subDataset>
<parameter name="logo" class="Object" isForPrompting="false">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<field name="waterlevelForecastData" class="com.example.reporting.WaterlevelForecastReportService.WaterlevelForecastData">
<fieldDescription><![CDATA[_THIS]]></fieldDescription>
</field>
<detail>
<band height="200">
<frame>
<reportElement x="0" y="0" width="100" height="42" uuid="a532b32e-a9e0-427b-84c4-d60fe9589d84">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<componentElement>
<reportElement x="0" y="0" width="100" height="42" isRemoveLineWhenBlank="true" uuid="f4166ea1-a21d-4ed8-8f16-02ae243c81f1">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
<property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="WaterLevelForecastDataSet" uuid="15b7c136-4802-4b6b-bd8c-cbde01ec9bed">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{waterlevelForecastData}.getWaterlevelForecastList())]]></dataSourceExpression>
</datasetRun>
<jr:column width="100" uuid="d70db54d-dd19-40c3-a36c-1d9592008fcc">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement style="Table_CH" x="0" y="0" width="100" height="30" uuid="7fa06c16-b4cc-450e-a204-6fe97e18c1a4">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<text><![CDATA[Datum]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="12">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField isStretchWithOverflow="true">
<reportElement style="DataStyle" x="0" y="0" width="100" height="12" uuid="75c92bc7-279f-4ea5-95dd-2005b43669f2">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat("E dd.MM.yyyy", $P{REPORT_LOCALE}).format($F{waterLevel}.getTime())]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</frame>
<frame>
<reportElement positionType="Float" x="570" y="0" width="230" height="200" uuid="386949ed-e289-4e9d-82af-54f7a1afbb6e"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement style="DataStyle" x="11" y="11" width="59" height="12" uuid="a63c6262-34f9-4731-9ad4-22bf6a2a54d2"/>
<textElement textAlignment="Left"/>
<text><![CDATA[Pegelort:]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="31" width="59" height="12" uuid="d56daa72-b14f-442b-8868-4bba5601f47f"/>
<textElement textAlignment="Left"/>
<text><![CDATA[Position:]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="51" width="58" height="12" uuid="056f6c4b-375e-4d88-8aa4-900da296b655"/>
<textElement textAlignment="Left"/>
<text><![CDATA[MHW (mPN):]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="71" width="57" height="12" uuid="30d9f8de-2612-4c2a-b319-39b01f6d2809"/>
<textElement textAlignment="Left"/>
<text><![CDATA[MNW (mPN):]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="91" width="57" height="12" uuid="51b3bc61-c9f3-4b48-9f72-df980ea80c2e"/>
<textElement textAlignment="Left"/>
<text><![CDATA[PN (mNN):]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="111" width="218" height="12" uuid="ddaea131-e7f8-4215-bada-f489b37896a9"/>
<textElement textAlignment="Left"/>
<text><![CDATA[Der Wasserstand bezieht sich auf Pegelnull.]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="123" width="29" height="12" uuid="54323c5e-1213-441f-9bda-41b6415d9158"/>
<textElement textAlignment="Left"/>
<text><![CDATA[HW]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="135" width="29" height="12" uuid="9974d608-8a33-4f35-ae72-07388f9ae138"/>
<textElement textAlignment="Left"/>
<text><![CDATA[NW]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="147" width="29" height="12" uuid="428c7ee2-46c1-4008-b355-8ac357c51057"/>
<textElement textAlignment="Left"/>
<text><![CDATA[MHW]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="159" width="29" height="12" uuid="81b95147-96f0-4227-b9a9-cf51c5db0c8c"/>
<textElement textAlignment="Left"/>
<text><![CDATA[MNW]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="183" width="29" height="12" uuid="38ef4fc2-05dd-4aae-8510-c50002d2492e"/>
<textElement textAlignment="Left"/>
<text><![CDATA[NN]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="11" y="171" width="29" height="12" uuid="8c9e77a4-65ea-4ef4-b8e4-b4b3620c3f0e"/>
<textElement textAlignment="Left"/>
<text><![CDATA[PN]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="123" width="160" height="12" uuid="66fd279e-95db-4970-b70f-aaa298929472"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Hochwasser]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="135" width="160" height="12" uuid="03b13ac8-169c-419c-a407-749b41c55f4a"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Niedrigwasser]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="147" width="160" height="12" uuid="f5bc3c27-f772-44d7-8679-f69a52d0f3e8"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Mittleres Hochwasser]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="159" width="160" height="12" uuid="8124681f-f321-4cde-986b-458318ef925f"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Mittleres Niedrigwasser]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="171" width="160" height="12" uuid="8bd1a23e-b9a6-48c9-afc3-8d01a901327a"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Pegelnull]]></text>
</staticText>
<staticText>
<reportElement style="DataStyle" x="40" y="183" width="160" height="12" uuid="96bb6dce-c1cd-490b-93f5-5aca18234fe2"/>
<textElement textAlignment="Left"/>
<text><![CDATA[= Normalnull]]></text>
</staticText>
</frame>
</band>
</detail>
<pageFooter>
<band height="30">
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" x="0" y="10" width="800" height="20" uuid="0d80af3a-fdab-42df-a876-9debf03164e8">
<property name="local_mesure_unitx" value="pixel"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Arial" size="7"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.hvcc.disclaimer}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
If I generate a PDF file from this report template, I'm always getting a blank page at the end, containing only the page footer and no content.
For my understanding this is because of the space between the table on the left side and the bottom of detail band 1, that will be added to the end of the table when the report is generated. So if the table and the space below is to large for one page, an additional page is added to the PDF containing only the space and footer.
If I remove the frame on the right side and reduce the height of detail band 1 to the end of the table, everything is fine and no extra page will be added. But I need this space in the report template because of the frame on the right side containing the static text.
How can I change the report template to reduce the height of detail band 1, so that no space below the table will be added to the PDF but with no effect to the definition of the frame on the right side?
I tried it many times by changing the stretch and overflow options but I'm always getting a blank page at the end.
Workaround
If I use a subreport for the frame on the right side and setting the height of the subreport element to the same height of the table on the left side, the height of detail band 1 can be reduced to the end of table and in the generated report no space will be added after the table and no extra page will be rendered.
But I thought there is a possibility to achieve this without using subreports.
Related
According to my design requirement, I am trying to create a simple Jasper report( using Jasper-soft Studio in 6.12 version) with Table in which the main report and table should be populated by java code using JRResultSetDataSource object with same query execution or data-source and also calculating the record count in page header, of the number of rows fetched in the table from the database.
But the problem is that- Either only table is getting populated through the data Source or only main report is getting populated or while providing same data-source to both main report and table then the first record of the table is missing because the record pointer in the data source is incremented as the data-source is passed from main report to table. Nor am I able to clone the data source to provide a copy of the data-source to the table as it is not supported for JRResultSetDataSource.
I want to use the same data-source to populate the table and to populate text fields present in the main report.
Java code-
Connection con;
Statement stmt;
ResultSet rs;
try {
Class.forName("org.postgresql.Driver");
con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/jasperexamples", "postgres", "password");
stmt=con.createStatement();
String query= "select * from product";
rs=stmt.executeQuery(query);
JRResultSetDataSource rsdt = new JRResultSetDataSource(rs);
String jasperReport = "/home/sakshi/JaspersoftWorkspace/MyReports/JasperProduct.jasper";
JasperPrint jp1 = JasperFillManager.fillReport(jasperReport, new HashMap<String, Object>(),rsdt);
JasperViewer jv = new JasperViewer(jp1);
jv.setVisible(true);
con.close();
}
catch(Exception e) {
e.printStackTrace();
}
Jrxml code-
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="JasperProduct" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0d6d7195-8cff-4512-be5d-258e505e6836">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1" uuid="0dc50125-a9d2-458b-82aa-27bfa253f3e9">
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="prouductname" class="java.lang.String"/>
<field name="productprize" class="java.lang.String"/>
<field name="company" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="prouductname" class="java.lang.String"/>
<field name="productprize" class="java.lang.String"/>
<field name="company" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<staticText>
<reportElement x="0" y="20" width="802" height="30" uuid="463c4bc3-254d-4c78-a35e-0096dc006165"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font size="24"/>
</textElement>
<text><![CDATA[Product Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="55" splitType="Stretch">
<staticText>
<reportElement x="5" y="17" width="110" height="30" uuid="836aa66c-e052-4ca1-ac75-feb821efa866"/>
<textElement verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Report Count]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement x="125" y="17" width="100" height="30" uuid="500a4853-c045-4897-a007-6e77598a31c7"/>
<textElement verticalAlignment="Middle">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="199" splitType="Stretch">
<componentElement>
<reportElement x="0" y="34" width="802" height="126" uuid="dc722ea3-7c31-439b-996c-bb3892426aea">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
<property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1" uuid="2c3773b9-e3a5-4046-a9d7-825487945fbb">
<datasetParameter name="REPORT_DATA_SOURCE">
<datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
<jr:columnGroup width="802" uuid="35fb663c-fc50-45f9-8715-575fe5aa27f4">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [4]"/>
<jr:tableHeader style="Table_TH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="802" height="30" uuid="9cdc6108-4308-449a-9995-182837f26b4d"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="18"/>
</textElement>
<text><![CDATA[Product Details]]></text>
</staticText>
</jr:tableHeader>
<jr:columnGroup width="802" uuid="2282f969-105d-4cf7-9714-ce0eef6e7a2a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [4]"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1">
<textField textAdjust="StretchHeight">
<reportElement mode="Opaque" x="0" y="0" width="802" height="30" uuid="4aa3d9f1-22dd-44bb-b002-b1fc83349c66"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:column width="200" uuid="88208a30-4a0d-4a22-8558-c9347efcab95">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="200" height="30" uuid="c7b0da69-05cb-4e00-b215-501476c06697"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="200" height="30" uuid="69c964ef-8985-4b28-adf2-eb89663ffa3c"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="190" uuid="26ed996c-7261-48e1-bfdd-5492a313bee9">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="190" height="30" uuid="294980bc-20b3-472e-999f-5be40daacf01"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Product Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="190" height="30" uuid="30e24e73-2357-40a9-ba78-a8dff9938ab9"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{prouductname}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="220" uuid="efd0925b-65d3-438e-950c-95fefc05998e">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="220" height="30" uuid="1480c534-2f5f-4cc7-96be-e275415b8cd0"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Product Prize]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="220" height="30" uuid="2df7f400-4845-4ebe-a874-c3ae91ccba2e"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{productprize}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="192" uuid="dfd8aead-b732-4300-8a47-29b0a6b7605b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="192" height="30" uuid="7fac6d69-f0eb-4ff2-82de-152872d9930d"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Company]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="192" height="30" uuid="701bebcf-d200-4cf8-bd88-37f4578be852"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{company}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</jr:columnGroup>
</jr:table>
</componentElement>
</band>
</detail>
<pageFooter>
<band height="62">
<staticText>
<reportElement x="0" y="20" width="160" height="30" uuid="dca10f20-8fa6-4e1b-8d48-16b549783ac6"/>
<box leftPadding="3">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement verticalAlignment="Middle">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[Company Name: ]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement x="160" y="20" width="642" height="30" uuid="2e69e42c-7588-429b-a0dc-42042e24bd61"/>
<box leftPadding="3">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$F{company}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
I have seen different approaches-
add a first empty row to the datasource before passing it to the
report.
passing two data sources- one to table and one to main
report.(But both work on the same datasource so it reduces the
performance).
But I don't think these approaches are good.
And also referred to different references but they didn't work according to my design requirement-
Why is my subdataset blank when I run report from Java code?
http://zetcode.com/articles/jaspertable/
http://junaedhalim.blogspot.com/2009/12/creating-jasperreport-with-subreports.html
https://community.jaspersoft.com/questions/540719/resolved-table-report-missing-1st-tablemodel-row
https://community.jaspersoft.com/questions/817326/table-not-displaying-any-values
Jasper Reports how to set data from JRResultSetDataSource into Table component
Can anyone please suggest a better approach for resolving this issue.
Thanks in advance
I have a requirement to create a table using JSON data using Jasperstudio 6.2.12 and export it to .xlsx format. I'm able to create the table as shown below:
The requirement I have is to iterate the values in A, B, C, and D columns based on the number of rows in the E and F columns. The expected output is:
The JSON data I've used to print the table is :
{
"root": [{
"firstName": "John",
"lastName": "Doe",
"accounts": [{
"bank": "LLOYDS",
"accountNumber": 123456,
"references": [{
"name": "Eva Doe",
"refAccountNumber": 6549873
},
{
"name": "Robin Doe",
"refAccountNumber": 3216545
},
{
"name": "Peter Doe",
"refAccountNumber": 9876549
}
]
}]
},
{
"firstName": "James",
"lastName": "Doe",
"accounts": [{
"bank": "HSBC",
"accountNumber": 654321,
"references": [{
"name": "Sam Doe",
"refAccountNumber": 6549873
},
{
"name": "Roger Doe",
"refAccountNumber": 3216545
},
{
"name": "Jason Doe",
"refAccountNumber": 9876549
}
]
}]
}
]}
JRXML:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 -->
<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="accounts" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="066cfa9f-bcf0-4095-8d82-a5ef1cb8632d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="true"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
<property name="net.sf.jasperreports.export.xls.white.page.background" value="false"/>
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
<property name="net.sf.jasperreports.export.xls.ignore.graphics" value="false"/>
<property name="net.sf.jasperreports.page.break.no.pagination" value="apply"/>
<property name="net.sf.jasperreports.export.xls.sheet.names.all" value="Accounts"/>
<property name="net.sf.jasperreports.export.xls.freeze.row" value="1"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
<property name="net.sf.jasperreports.exports.xls.font.size.fix.enabled" value="false"/>
<property name="maximumRowsPerSheet" value="0"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="AccountsDataset" uuid="73085770-27bc-42cb-b4db-edc97074de2c">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<queryString language="json">
<![CDATA[root.accounts]]>
</queryString>
<field name="bank" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="bank"/>
<fieldDescription><![CDATA[bank]]></fieldDescription>
</field>
<field name="accountNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="accountNumber"/>
<fieldDescription><![CDATA[accountNumber]]></fieldDescription>
</field>
<field name="accoutType" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="accoutType"/>
<fieldDescription><![CDATA[accoutType]]></fieldDescription>
</field>
<field name="references" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="references"/>
<fieldDescription><![CDATA[references]]></fieldDescription>
</field>
</subDataset>
<subDataset name="ReferencesDataset" uuid="b23c5f84-b106-4d89-a5d4-6287aa8bbdf7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<queryString language="json">
<![CDATA[root.accounts.references]]>
</queryString>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="refAccountNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="refAccountNumber"/>
<fieldDescription><![CDATA[refAccountNumber]]></fieldDescription>
</field>
</subDataset>
<subDataset name="MainDataset" uuid="ab297ea1-81e6-4a6f-b90c-4ce1fb9521a2">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<queryString language="json">
<![CDATA[root]]>
</queryString>
<field name="firstName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="firstName"/>
<fieldDescription><![CDATA[firstName]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="lastName"/>
<fieldDescription><![CDATA[lastName]]></fieldDescription>
</field>
<field name="email" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="email"/>
<fieldDescription><![CDATA[email]]></fieldDescription>
</field>
<field name="accounts" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="accounts"/>
<fieldDescription><![CDATA[accounts]]></fieldDescription>
</field>
</subDataset>
<queryString language="json">
<![CDATA[]]>
</queryString>
<field name="root" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="root"/>
<fieldDescription><![CDATA[root]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="254" splitType="Stretch">
<componentElement>
<reportElement x="0" y="0" width="480" height="60" uuid="268fe625-e43f-48d5-90c7-f396d09cd88d">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="MainDataset" uuid="67830a07-2594-4532-ae34-96829b8046da">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("root")]]></dataSourceExpression>
</datasetRun>
<jr:column width="80" uuid="a8cf3aa0-1633-4f19-a908-6efbf55d2f75">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="b89609d4-5cbb-4f5b-b470-c9f9f4ad9d26"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[First Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="ec954e2c-43e4-43ba-9005-03272b9daad5"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="e7f5cfca-a803-485d-be01-5d2f785fbf0b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="0a2eb2ed-75b9-46c3-8751-871c5473c3e1"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Last Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="767b9d15-53e5-4a0b-be8c-ec94fc6398f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="c7103510-df1d-4c31-a30f-9b726540dd7a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="11192151-2c03-4590-91f7-87021b022301"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Bank]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<componentElement>
<reportElement x="0" y="0" width="80" height="30" uuid="8b2678af-1b87-49e6-aca2-af0cec3d7a46"/>
<jr:list printOrder="Vertical">
<datasetRun subDataset="AccountsDataset" uuid="faa7fa1c-7169-48fb-aac2-7483a2477998">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("accounts")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="80">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="97ec29f7-36f2-4ecc-9f30-3049e0648e97"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{bank}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="5a4bb23a-7d61-486b-91f8-b5150cb85817">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="30680d44-df3b-484e-b059-399e0a21b304"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Account Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<componentElement>
<reportElement x="0" y="0" width="80" height="30" uuid="d7780443-ba11-4d20-944d-4f8210a74506"/>
<jr:list printOrder="Vertical">
<datasetRun subDataset="AccountsDataset" uuid="2c245f1d-7a8f-46dc-85c3-737b5b0bc5a1">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("accounts")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="80">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="ba6b13f3-770d-4a02-b3f0-5d4293393cd3"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{accountNumber}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="0720c554-a0af-4192-a669-38cea560a2e2">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="98adb234-9003-4704-85e4-295538f4273c"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Ref Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<componentElement>
<reportElement x="0" y="0" width="80" height="30" uuid="faf83492-91ac-4a39-9483-512d6555c3d3"/>
<jr:list printOrder="Vertical">
<datasetRun subDataset="ReferencesDataset" uuid="832a218b-199c-4055-9891-0afaf629bf50">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("accounts.references")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="80">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="955502f3-afec-40aa-a8f8-b5e83d43bcbc"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="2aed257e-00f2-4594-a9ac-9b504262ee3e">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="be058bb0-b9f3-4b41-b074-c1f44350eb09"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Ref Account Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<componentElement>
<reportElement x="0" y="0" width="80" height="30" uuid="ed5f0c5e-8f14-4565-8159-b7528e035f3c"/>
<jr:list printOrder="Vertical">
<datasetRun subDataset="ReferencesDataset" uuid="2c2d0c12-930c-45c5-a3a1-f8228fc78d7f">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("accounts.references")]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="30" width="80">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="59563298-0f0f-4b62-b263-511abb945d1a"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{refAccountNumber}]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
Please help me to iterate the values in A, B, C, and D columns based on the number of rows in the E and F columns and get the expected output. Thank you all so much!
The easiest way to do this is to use a single subdataset that has the fields from all levels of the JSON tree. To do that you'll have to switch to the JSONQL query executer, which allows you to map fields from the parent nodes of the ones selected by the data source.
Once you have all the fields in a single dataset, you can use a simple table to display them.
The report would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 -->
<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="accounts" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="066cfa9f-bcf0-4095-8d82-a5ef1cb8632d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="true"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>
<property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
<property name="net.sf.jasperreports.export.xls.white.page.background" value="false"/>
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
<property name="net.sf.jasperreports.export.xls.ignore.graphics" value="false"/>
<property name="net.sf.jasperreports.page.break.no.pagination" value="apply"/>
<property name="net.sf.jasperreports.export.xls.sheet.names.all" value="Accounts"/>
<property name="net.sf.jasperreports.export.xls.freeze.row" value="1"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
<property name="net.sf.jasperreports.exports.xls.font.size.fix.enabled" value="false"/>
<property name="maximumRowsPerSheet" value="0"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="ReferencesDataset" uuid="b23c5f84-b106-4d89-a5d4-6287aa8bbdf7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Test"/>
<queryString language="jsonql">
<![CDATA[root.accounts.references]]>
</queryString>
<field name="firstName" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^^^^.firstName"/>
<fieldDescription><![CDATA[firstName]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^^^^.lastName"/>
<fieldDescription><![CDATA[lastName]]></fieldDescription>
</field>
<field name="bank" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^^.bank"/>
<fieldDescription><![CDATA[bank]]></fieldDescription>
</field>
<field name="accountNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.jsonql.field.expression" value="^^.accountNumber"/>
<fieldDescription><![CDATA[accountNumber]]></fieldDescription>
</field>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="refAccountNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.jsonql.field.expression" value="refAccountNumber"/>
<fieldDescription><![CDATA[refAccountNumber]]></fieldDescription>
</field>
</subDataset>
<queryString language="jsonql">
<![CDATA[]]>
</queryString>
<field name="root" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="root"/>
<fieldDescription><![CDATA[root]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="254" splitType="Stretch">
<componentElement>
<reportElement x="0" y="0" width="480" height="60" uuid="268fe625-e43f-48d5-90c7-f396d09cd88d">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="ReferencesDataset" uuid="67830a07-2594-4532-ae34-96829b8046da">
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("root.accounts.references.*")]]></dataSourceExpression>
</datasetRun>
<jr:column width="80" uuid="a8cf3aa0-1633-4f19-a908-6efbf55d2f75">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="b89609d4-5cbb-4f5b-b470-c9f9f4ad9d26"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[First Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="ec954e2c-43e4-43ba-9005-03272b9daad5"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{firstName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="e7f5cfca-a803-485d-be01-5d2f785fbf0b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="0a2eb2ed-75b9-46c3-8751-871c5473c3e1"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Last Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="767b9d15-53e5-4a0b-be8c-ec94fc6398f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{lastName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="c7103510-df1d-4c31-a30f-9b726540dd7a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="11192151-2c03-4590-91f7-87021b022301"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Bank]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="97ec29f7-36f2-4ecc-9f30-3049e0648e97"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{bank}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="5a4bb23a-7d61-486b-91f8-b5150cb85817">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="30680d44-df3b-484e-b059-399e0a21b304"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Account Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="ba6b13f3-770d-4a02-b3f0-5d4293393cd3"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{accountNumber}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="0720c554-a0af-4192-a669-38cea560a2e2">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="98adb234-9003-4704-85e4-295538f4273c"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Ref Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="955502f3-afec-40aa-a8f8-b5e83d43bcbc"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="80" uuid="2aed257e-00f2-4594-a9ac-9b504262ee3e">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement x="0" y="0" width="80" height="30" uuid="be058bb0-b9f3-4b41-b074-c1f44350eb09"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Ref Account Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField>
<reportElement x="0" y="0" width="80" height="30" uuid="59563298-0f0f-4b62-b263-511abb945d1a"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{refAccountNumber}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
</jasperReport>
I am getting error when using sub report in jasper report.
First there was an error of resource not found: subreport.jrxml
Then the second error was subreport was not showing in the master report.
Now there is a new error and i am unable to sort it out.
This is the stack trace of my error.
"C:\Program Files\Java\jdk1.8.0_231\bin\java.exe"
"-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2019.2.3\lib\idea_rt.jar=38754:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program
Files\Java\jdk1.8.0_231\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\access-bridge-64.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\cldrdata.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\jaccess.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\jfxrt.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\nashorn.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunec.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunmscapi.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunpkcs11.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\zipfs.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jfr.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jfxswt.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\management-agent.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\rt.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\out\production\Medicare;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\fontawesomefx-8.9.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\mysql-connector.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-beanutils-1.8.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-collections-3.2.1-1.0.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-digester-2.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-logging-1.1.1-1.0.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-logging-1.1.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\groovy-all-2.0.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\itext-2.1.7.js2.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined Libs\jasperreports-5.6.0.jar" model.Main Exception
in thread "JavaFX Application Thread" java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException at
javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774) at
javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Node.fireEvent(Node.java:8411) at
javafx.scene.control.Button.fire(Button.java:185) at
com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at
com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at
javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at
javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at
javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method) at
com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
at
com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at
com.sun.glass.ui.View.notifyMouse(View.java:937) at
com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at
com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at
sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) at
javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771) ...
48 more Caused by: net.sf.jasperreports.engine.JRException: Errors
were encountered when compiling report expressions class file:
C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:246: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:364: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:482: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ 3 errors
at
net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:204)
at
net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:354)
at
net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:340)
at
net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:605)
at
controller.ViewPendingOrders.generateInvoice(ViewPendingOrders.java:123)
... 58 more
Master Jasper Report.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<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="Invoice" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#EEEFF0"/>
</conditionalStyle>
</style>
<style name="Table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="1.0" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#CACED0">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style backcolor="#D8D8D8"/>
</conditionalStyle>
</style>
<subDataset name="tableDataset" uuid="f13e6d36-5148-4ecc-bbe3-3035def80980">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<parameter name="TestParameter" class="java.lang.String"/>
<parameter name="listOfItems" class="java.util.ArrayList"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="orderId" class="java.lang.String"/>
<field name="dealerId" class="java.lang.String"/>
<field name="dealerName" class="java.lang.String"/>
<field name="dealerAddress" class="java.lang.String"/>
<field name="dealerContact" class="java.lang.String"/>
<field name="orgPrice" class="java.lang.String"/>
<field name="bonus" class="java.lang.String"/>
<field name="discount" class="java.lang.String"/>
<field name="finalPrice" class="java.lang.String"/>
<field name="listOfItems" class="java.util.ArrayList"/>
<detail>
<band height="503">
<staticText>
<reportElement x="1" y="240" width="100" height="20" uuid="023f299c-597f-46e6-b9bb-8330926484e4"/>
<text><![CDATA[Bonus]]></text>
</staticText>
<textField>
<reportElement x="1" y="264" width="362" height="46" uuid="c75b5fd2-6c4b-480b-91a3-9440ca3c71fa"/>
<textFieldExpression><![CDATA[$F{bonus}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="380" y="244" width="84" height="16" uuid="2560e5b8-b3f2-4962-9e4a-7890ee48eb84"/>
<text><![CDATA[Invoice Payment]]></text>
</staticText>
<staticText>
<reportElement x="380" y="264" width="84" height="16" uuid="c7d9167e-2c29-41af-9a2b-d576f5d5cf33"/>
<text><![CDATA[Discount]]></text>
</staticText>
<staticText>
<reportElement x="380" y="284" width="84" height="16" uuid="3ed37e4e-be08-4dd8-a751-0b788a4ebc54"/>
<text><![CDATA[Payable Payments]]></text>
</staticText>
<textField>
<reportElement x="465" y="282" width="90" height="18" uuid="6ef42f61-bd40-4db6-82e2-793c47f72ccc"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{finalPrice}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="465" y="264" width="90" height="16" uuid="62dbd5d9-18ee-49c8-a868-740087d110b1"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{discount}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="465" y="244" width="90" height="16" uuid="453a26cb-3638-4bf7-9222-643d10f48207"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{orgPrice}]]></textFieldExpression>
</textField>
<line>
<reportElement x="1" y="233" width="555" height="1" uuid="44809847-2137-43f5-aef1-e7f4e8c76491"/>
</line>
<staticText>
<reportElement positionType="Float" x="0" y="339" width="261" height="101" uuid="1a0d7088-5af7-4865-8be1-41ec5f51fb36"/>
<box>
<topPen lineWidth="1.1" lineStyle="Dashed"/>
<leftPen lineWidth="1.1" lineStyle="Dashed"/>
<bottomPen lineWidth="1.1" lineStyle="Dashed"/>
<rightPen lineWidth="1.1" lineStyle="Dashed"/>
</box>
<text><![CDATA[Your notes here
Your notes here
Your notes here
Your notes here
Your notes here]]></text>
</staticText>
<staticText>
<reportElement x="0" y="5" width="210" height="25" uuid="e622555d-198b-4ccd-a4a1-c59c53304058">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="19" isBold="true"/>
</textElement>
<text><![CDATA[Younas Traders]]></text>
</staticText>
<staticText>
<reportElement x="0" y="30" width="205" height="15" uuid="c226e44d-3bb5-4145-b0b3-903bf1d79fde"/>
<text><![CDATA[Street address]]></text>
</staticText>
<staticText>
<reportElement x="0" y="45" width="205" height="15" uuid="b96f7183-44f8-43ad-ba60-43d8fbf50b6e"/>
<text><![CDATA[City, street, ZIP code]]></text>
</staticText>
<staticText>
<reportElement x="0" y="60" width="205" height="15" uuid="b8cc42fd-b569-497d-834d-7e854040ad18"/>
<text><![CDATA[Phone number, web address, ecc.]]></text>
</staticText>
<staticText>
<reportElement x="0" y="90" width="84" height="25" uuid="57aed2b1-4f4e-40a3-a6ad-54dae8dd4c5a">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Bill to]]></text>
</staticText>
<staticText>
<reportElement x="0" y="115" width="40" height="15" uuid="33274f5d-5b7e-4be2-a2ff-65d452a618ed"/>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement x="0" y="130" width="40" height="15" uuid="1d3045ed-03d6-4253-a959-aeeb491b73ca"/>
<text><![CDATA[Name]]></text>
</staticText>
<textField>
<reportElement x="40" y="115" width="140" height="15" uuid="424a926c-30f5-48ba-965e-e9c64ea93c09"/>
<textFieldExpression><![CDATA[$F{dealerId}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="40" y="130" width="140" height="15" uuid="b3fd9ce4-cab2-4102-882a-1f51e38fef4e"/>
<textFieldExpression><![CDATA[$F{dealerName}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="465" y="10" width="84" height="20" uuid="bb10dbe1-0a4f-4722-9953-c163b63cf979"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="415" y="10" width="50" height="20" uuid="0f86baff-6386-4f3f-b3fe-2388707babe8"/>
<box rightPadding="4"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Date:]]></text>
</staticText>
<staticText>
<reportElement x="415" y="30" width="50" height="20" uuid="0b3f9342-da78-4cfa-9fc5-2301c4749678"/>
<box rightPadding="4"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Invoice #]]></text>
</staticText>
<textField>
<reportElement x="465" y="30" width="84" height="20" uuid="c108d3cf-4809-4862-abca-6ed67e9f6066"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{orderId}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="360" y="115" width="50" height="15" uuid="235bf8b6-1e1e-49c7-b59f-7a46c30b8209"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Address]]></text>
</staticText>
<staticText>
<reportElement x="360" y="90" width="196" height="25" uuid="139ebe8d-25b0-411e-986c-270015400874">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Contact Info]]></text>
</staticText>
<textField>
<reportElement x="410" y="115" width="146" height="15" uuid="92657a77-3115-4437-9c5c-79cd3a7b8de7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{dealerAddress}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="410" y="131" width="146" height="14" uuid="70bf5644-2451-4079-ad60-00d7462e5029"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{dealerContact}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="360" y="130" width="50" height="15" uuid="665f25c2-8663-4951-b699-1ab863bdeb76"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Contact]]></text>
</staticText>
<line>
<reportElement x="-10" y="84" width="556" height="1" uuid="806ce5df-1219-4876-ae0c-ca7405b1f246">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
<break>
<reportElement x="0" y="480" width="556" height="1" uuid="210638e1-1901-4517-bef1-aad33e0bf0d2"/>
</break>
<subreport>
<reportElement x="3" y="180" width="552" height="40" uuid="e328f355-34f5-4f03-b487-f3976e3363f0"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfItems})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{listOfItems}]]]></subreportExpression>
</subreport>
</band>
</detail>
<lastPageFooter>
<band height="71"/>
</lastPageFooter>
</jasperReport>
Sub Report
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<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="ItemsDetail" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="017e107d-3aa8-4a1e-8830-154cd4e30b51">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="itemNo" class="java.lang.String"/>
<field name="itemName" class="java.lang.String"/>
<field name="quantity" class="java.lang.String"/>
<field name="unit" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="36" splitType="Stretch">
<staticText>
<reportElement x="0" y="10" width="40" height="26" uuid="a41d735b-427a-407f-ab30-823815930dbc">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="f0337735-db21-4453-bf38-5b2818b709bd"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Sr No.]]></text>
</staticText>
<staticText>
<reportElement x="40" y="10" width="80" height="26" uuid="2932eb5f-61e2-4ec9-a398-06110d34db6f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="25158f69-d1fc-4a93-a0c0-a631797fcf41"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Item No]]></text>
</staticText>
<staticText>
<reportElement x="120" y="10" width="270" height="26" uuid="07ca2115-2395-4a57-b1b0-49bce35d7ae9">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1b19a0c1-1fe2-4816-a6f4-d6537129a33d"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Item Name]]></text>
</staticText>
<staticText>
<reportElement x="390" y="10" width="80" height="26" uuid="ae2b917d-3dd1-4543-89d6-617847e668c6">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="93a5ea62-c6bc-4420-8220-beb00fa064c8"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Quantity]]></text>
</staticText>
<staticText>
<reportElement x="470" y="10" width="85" height="26" uuid="48e2794a-6a19-4012-b023-31366dc43306">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="dde337f4-f033-42bb-8533-654ccdea99d0"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Unit]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="40" splitType="Stretch">
<textField>
<reportElement x="40" y="0" width="80" height="20" uuid="21fd205d-e27c-41db-89d3-bc2e34001baf">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="25158f69-d1fc-4a93-a0c0-a631797fcf41"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{itemNo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="0" width="270" height="20" uuid="c389cf68-9eb4-4de4-a38a-2d0a184267a7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1b19a0c1-1fe2-4816-a6f4-d6537129a33d"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{itemName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="390" y="0" width="80" height="20" uuid="eec1bb74-3a3b-4e3e-a946-f192c17129c2">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="93a5ea62-c6bc-4420-8220-beb00fa064c8"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="470" y="0" width="85" height="20" uuid="060897c5-c6bc-41db-b4bb-74f9b0930522">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="dde337f4-f033-42bb-8533-654ccdea99d0"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{unit}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="40" height="20" uuid="f5e5a0a4-ed77-4744-8aac-dd546115e273"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{COLUMN_COUNT}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
There's an additional closing ] in the XML fragment below:
<subreportExpression><![CDATA[$P{listOfItems}]]]></subreportExpression>
Remove it to fix the error:
<subreportExpression><![CDATA[$P{listOfItems}]]></subreportExpression>
subreportExpression element value represents the compiled sub report (.jasper) file name (file path with file name). it support to values from following classes,
java.lang.String (default)
java.io.File
java.io.InputStream
java.net.URL
JasperReport
in your case, declared a parameter as listOfItems with calss type java.util.ArrayList and it passed to subreportExpression. but java.util.ArrayList class type is not supported to subreportExpression
try with one of the following methods,
pass sub report name and sub report file path directly to subreportExpression.
<subreportExpression><![CDATA["Your Sub Report File Path/ItemsDetail.jasper"]]></subreportExpression> // sub report name is a ItemaDetail
declared a parameter with class type java.lang.String then, it pass to subreportExpression.
<parameter name="SUB_REPORT_FILE" class="java.lang.String"/>
<subreportExpression><![CDATA[$P{SUB_REPORT_FILE}]]></subreportExpression>
in run time you should pass the sub report file name to SUB_REPORT_FILE parameter in java application as given below,
HashMap<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("SUB_REPORT_FILE", "Your Sub Report File Path/ItemsDetail.jasper");
JasperPrint jasperPrint = JasperFillManager.fillReport("Your Master Report File Path/Invoice.jasper", parameterMap, YOUR_JRBeanCollectionDataSource); // master report name is a Invoice
or,
pass SUB_REPORT_FILE parameter with sub report file name to subreportExpression and set the sub report file path only at run time
in master report (Invoice.jrxml),
<subreportExpression><![CDATA[$P{SUB_REPORT_FILE}+"/ItemsDetail.jasper"]]></subreportExpression>
in java application,
HashMap<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("SUB_REPORT_FILE", "Your Sub Report File Path"); // pass the sub report file path only
JasperPrint jasperPrint = JasperFillManager.fillReport("Your Master
Report File Path/Invoice.jasper", parameterMap, YOUR_JRBeanCollectionDataSource);
This question already has answers here:
jasper ireport create a report with parameters without sql query
(1 answer)
Why Jasper Reports shows empty report in server, but generates correctly in jasper studio
(2 answers)
Getting blank report generated in JasperReports using bean datasource and subreports
(1 answer)
My Jasper Template shows no text
(1 answer)
Closed 3 years ago.
I have a Jasper Report that has a title followed by details. When there are details in the report, the title shows. But when the report has no details, the title does not show.
I would like the title to be fixed, so that it shows no matter whether there are details or not. I already have it configured this way for a separate report. The only difference between the two reports is that the second report (which has a fixed header that shows no matter what) does not use frames, whereas this report (the problematic one) does use frames.
Here is the XML for the title section of my problematic report that does not show a fixed header.
Any idea why the title is not showing in the case that there are no report details? I do use static text, after all... I'm not sure why the static text doesn't show.
<title>
<band height="60" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<frame>
<reportElement style="Title" mode="Opaque" x="0" y="0" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="f5eeff7b-82c8-4e5e-b89f-c8f4e0bf230e">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
</box>
<staticText>
<reportElement x="332" y="0" width="134" height="20" uuid="ff17f385-30ec-417d-bf55-2f79996f0ca9">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Sign Audit Report]]></text>
</staticText>
</frame>
<frame>
<reportElement mode="Opaque" x="0" y="20" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="f9c0304d-0864-46b3-8b18-b28b20d8c7de">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
</box>
<textField>
<reportElement x="299" y="0" width="190" height="19" uuid="ace3db7b-5c61-4205-98e9-872483bc9206"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{STORE_ID} +" - "+$P{STORE_NAME}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement mode="Opaque" x="0" y="40" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="b0c895f6-6dbd-477d-9858-9ad66af087e1">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
</box>
<staticText>
<reportElement x="0" y="0" width="99" height="20" uuid="d37d9a5e-2dad-4774-8b62-87a458b25902">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="10"/>
</textElement>
<text><![CDATA[Report generated on :]]></text>
</staticText>
<textField pattern="MM/dd/yyyy">
<reportElement x="99" y="0" width="122" height="20" uuid="e4e59db3-b1d7-4f84-8052-96d6c4ea34a1">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format(new Date())]]></textFieldExpression>
</textField>
<textField pattern="MM/dd/yyyy">
<reportElement x="641" y="0" width="150" height="20" uuid="98a8efa4-19ae-4d06-8874-12482bd8aeb1">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format($P{effStartDate})+" - "+new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format($P{endDate})]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="579" y="0" width="64" height="20" uuid="6dfe0bf6-cd90-48b2-9cc9-7bad865a9c66">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="10"/>
</textElement>
<text><![CDATA[Signs Active :]]></text>
</staticText>
</frame>
</band>
</title>
I have a query as below. I'd like to display number of requests for the 3 consecutive fiscal years (FY1, FY2, FY3). The bar graph only shows data for FY1. How do I display 3 bars within the graph?
select count(unique(p1.requestNumber)) as FY1, count(unique(p2.requestNumber)) as FY2, count(unique(p3.requestNumber)) as FY3
from fd.bankRequest P1, fd.bankRequest P2, fd.bankRequest P3
where
to_char(P1.requestDate, 'yyyymm') between (to_char(sysdate, 'yyyy')|| '10') and to_char(sysdate, 'yyyymm')
and
(to_char(P2.requestDate, 'yyyymm') between (to_number(to_char(sysdate, 'yyyy') -1) || '10') and (to_char(sysdate, 'yyyy') || '09'))
and
(to_char(P3.requestDate, 'yyyymm') between (to_number(to_char(sysdate, 'yyyy') -2) || '10') and (to_number(to_char(sysdate, 'yyyy') -1) || '09'))
and
to_number(to_char(sysdate, 'mm')) >= 10
The jrxml codes as below
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.1.final using JasperReports Library version 6.2.1 -->
<!-- 2016-11-23T12:32:37 -->
<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="FYRpt" language="groovy" pageWidth="612" pageHeight="792" whenNoDataType="AllSectionsNoDetail" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryWithPageHeaderAndFooter="true" isIgnorePagination="true" uuid="8a465670-cc4a-4270-965f-8efb86e33b71">
<property name="template.engine" value="tabular_template"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="ojdbc7"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<style name="Table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="1.0" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 3_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 3_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table 3_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="FiscalYear" uuid="653c97d8-f01f-433a-8f37-19831ca0c04e">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="ojdbc7"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[select count(unique(p1.requestNumber)) as FY1, count(unique(p2.requestNumber)) as FY2, count(unique(p3.requestNumber)) as FY3
from fd.bankRequest P1, fd.bankRequest P2, fd.bankRequest P3
where
to_char(P1.requestDate, 'yyyymm') between (to_char(sysdate, 'yyyy')|| '10') and to_char(sysdate, 'yyyymm')
and
(to_char(P2.requestDate, 'yyyymm') between (to_number(to_char(sysdate, 'yyyy') -1) || '10') and (to_char(sysdate, 'yyyy') || '09'))
and
(to_char(P3.requestDate, 'yyyymm') between (to_number(to_char(sysdate, 'yyyy') -2) || '10') and (to_number(to_char(sysdate, 'yyyy') -1) || '09'))
and
to_number(to_char(sysdate, 'mm')) >= 10]]>
</queryString>
<field name="FY1" class="java.math.BigDecimal"/>
<field name="FY2" class="java.math.BigDecimal"/>
<field name="FY3" class="java.math.BigDecimal"/>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="60" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<image>
<reportElement x="0" y="0" width="222" height="36" uuid="a9fbad6a-651d-43cd-bfb6-2cf334d623ed"/>
<imageExpression><![CDATA["C:/jboss-eap-6.4/NX-runtime/reports/Images/Logo.png"]]></imageExpression>
</image>
<staticText>
<reportElement x="280" y="0" width="209" height="30" uuid="4d5423b2-708b-4afa-9ffd-f7ce5b8135f6"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[Executive Summary]]></text>
</staticText>
<textField isStretchWithOverflow="true" pattern="">
<reportElement x="380" y="30" width="191" height="20" forecolor="#000000" uuid="d770f29c-b0d4-4161-87d6-db5a2c36754e">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA["Report created on " + new SimpleDateFormat("MM/dd/yyyy HH:mm").format(new Date())]]></textFieldExpression>
</textField>
</band>
</title>
<pageFooter>
<band height="65">
<textField>
<reportElement positionType="Float" x="210" y="40" width="361" height="20" uuid="6ca8797f-653d-46a0-a24f-d286078dccc8"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="11"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER} + " of " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="581" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<textField>
<reportElement x="10" y="0" width="570" height="20" uuid="8956e672-accf-461b-b2b1-e81f70e8e87e">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Fiscal Year Report"]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="10" y="50" width="200" height="120" uuid="eba4eb25-553f-424c-aba2-c124b35957cb">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table 3_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table 3_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table 3_TD"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="FiscalYear" uuid="e5979756-be6d-498c-8502-b9217b605591">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="110" uuid="b11b4e94-29e6-497e-8534-55832acd42d9">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:tableFooter style="Table 3_TH" height="30" rowSpan="1">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="110" height="30" uuid="e1165115-bb42-4a58-bb64-96782790ae11"/>
<box leftPadding="6"/>
<textElement verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA["FY " + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),1))]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:columnHeader style="Table 3_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="110" height="30" uuid="a5e2a06a-8ab3-471b-82a1-dd9288957ede"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Fiscal Year (FY)]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table 3_CH" height="30" rowSpan="1">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="110" height="30" uuid="61a4651f-cb1d-416f-a32e-68beb2d1c219"/>
<box leftPadding="6"/>
<textElement verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA["FY " + YEAR(TODAY())]]></textFieldExpression>
</textField>
</jr:columnFooter>
<jr:detailCell style="Table 3_TD" height="30">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="110" height="30" uuid="6eb9c024-cc8f-4810-bf96-22de20b8eca7"/>
<box leftPadding="6"/>
<textElement verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA["FY " + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),-1))]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="a0501979-12d2-43ab-9f50-c3a0814888c4">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:tableFooter style="Table 3_TH" height="30" rowSpan="1">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="90" height="30" forecolor="#000000" uuid="d1c24563-2f4c-4948-92a5-507a91344541"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$F{FY3}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:columnHeader style="Table 3_CH" height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="90" height="30" uuid="64033655-a2a1-4260-84bb-940d2e71fcc1"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Total Requests]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="Table 3_CH" height="30" rowSpan="1">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="90" height="30" uuid="43b0b490-b093-482f-a6b5-6473ffa4ba6d"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$F{FY2}]]></textFieldExpression>
</textField>
</jr:columnFooter>
<jr:detailCell style="Table 3_TD" height="30">
<textField>
<reportElement mode="Opaque" x="0" y="0" width="90" height="30" uuid="00bdeea7-5bea-4d71-8ef7-29cf59c25df6"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$F{FY1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
<barChart>
<chart evaluationTime="Report" theme="eye.candy.sixties">
<reportElement x="240" y="50" width="322" height="190" uuid="91806aa7-467e-4cf4-a723-e6de7db10c18"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset>
<datasetRun subDataset="FiscalYear" uuid="f3908198-41a0-41b6-99d5-0af1af893936">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
<categorySeries>
<seriesExpression><![CDATA["FY " + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),-1))]]></seriesExpression>
<categoryExpression><![CDATA[($F{FY1} ? "FY" + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),-1))
: $F{FY2} ? "FY " + YEAR(TODAY())
: "FY " + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),1)))]]></categoryExpression>
<valueExpression><![CDATA[$F{FY1}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["FY " + YEAR(TODAY())]]></seriesExpression>
<categoryExpression><![CDATA[0]]></categoryExpression>
<valueExpression><![CDATA[0]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["FY " + new SimpleDateFormat("yyyy").format(org.apache.commons.lang.time.DateUtils.addYears(TODAY( ),1))]]></seriesExpression>
<categoryExpression><![CDATA[0]]></categoryExpression>
<valueExpression><![CDATA[0]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot isShowLabels="true">
<plot/>
<itemLabel/>
<categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>
</barChart>
</band>
</summary>
</jasperReport>