So im trying shrink the right frame when the last two inside frames containing the
text fields(red boxes) are blank. The left and right main frames are also inside a frame. But even if only have 4 rows i always get the unused space in the report.
<detail>
<band height="11" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<printWhenExpression><![CDATA[$V{REPORT_COUNT}>1]]></printWhenExpression>
</band>
<band height="71" splitType="Stretch">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="554" height="71" isRemoveLineWhenBlank="true" uuid="603f6666-1471-4d16-b0aa-bde352f18b8e">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<frame>
<reportElement style="Default" stretchType="RelativeToTallestObject" x="0" y="0" width="301" height="50" isRemoveLineWhenBlank="true" uuid="a12bdb49-abd3-4ecf-83db-033e5846174d"/>
<frame>
<reportElement positionType="Float" x="0" y="20" width="300" height="10" isRemoveLineWhenBlank="true" uuid="ec17f3b3-e6e1-4f57-89e1-3499e4aa63cb">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!(EXACT(continitions]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="96082d63-b65e-4461-951d-6f6532ca9fe0">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["Morada"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="227f2a1f-3fc6-4fbf-a680-6d4ec4bbf86b"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[(condditions]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="30" width="300" height="10" isRemoveLineWhenBlank="true" uuid="115c7def-a074-4164-8738-649cecaa095a">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[conditions]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="d46cb243-e8e7-4775-9abb-c8600e44f884">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="" x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="c9f0f6dc-9fc3-49bd-ac4c-7de41ac07633"/>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[conditions]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="10" width="300" height="10" isRemoveLineWhenBlank="true" uuid="016e4775-e417-4f5c-a4de-b0be970e9d3a">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" uuid="e4e78c67-a0c0-4d01-9942-3429ce402bc5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$(field)]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" uuid="6b3ac9a8-28a5-413e-9348-e9625f94c235">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement x="0" y="0" width="300" height="10" isRemoveLineWhenBlank="true" uuid="7f7b2531-9450-4a9f-b311-625df5ccae4f">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="80" height="10" isRemoveLineWhenBlank="true" uuid="c5a3d310-c74f-4546-97b0-18aa4de9a45a">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="58" y="0" width="218" height="10" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="649b1963-912c-4902-8052-1320e32e67ab">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
</frame>
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="301" y="0" width="244" height="70" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="c1a1530c-2fca-43d8-a238-f48f3290da29">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<frame>
<reportElement positionType="Float" x="0" y="40" width="244" height="10" isRemoveLineWhenBlank="true" uuid="a96e6e9f-e02f-4e9b-a900-2e55a33df0f3">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition)))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="edb4759b-cf68-4367-8bc4-7e07364ae3c5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" isPrintWhenDetailOverflows="true" uuid="48766f62-03de-407a-a771-6e82e5a4c7ff">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="10" width="244" height="10" isRemoveLineWhenBlank="true" uuid="acbe8ba0-af8d-4e1a-93a8-7305a02839a6">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition)))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="d14807d2-aa00-421f-9dab-7cce0adf758a">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="63e62a4d-9dca-4dca-85f5-515a4ee18d0b">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{locationscope_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="0" width="244" height="10" isRemoveLineWhenBlank="true" uuid="cc62c22d-cc19-4461-ba53-74f4ba733322">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="6ce16cc5-2a18-4b3d-a7f7-17979a0a111b">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="cc7b895b-2e4f-4118-830f-1bde2e181be6">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{scope_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="30" width="244" height="10" isRemoveLineWhenBlank="true" uuid="4c9ae6a0-6534-4952-be6c-7a18d8351a3c">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})))]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="1c8aedb1-020b-4d7f-aea2-93b0557b2c23">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="c7ae3de9-2f2d-4178-85b2-bf2091766558">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="20" width="244" height="10" isRemoveLineWhenBlank="true" uuid="8f058c9f-27d5-4f0f-8eac-32a58fa7ad06">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<printWhenExpression><![CDATA[!($F{condition})]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="ba3f46e3-c823-4815-a74d-7a4caa77828f">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="75cce569-0fc5-425b-a9fc-9a42516a4305">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="50" width="244" height="10" isRemoveLineWhenBlank="true" uuid="18fad1eb-f42f-4876-be03-40aac2765875">
<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_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<printWhenExpression><![CDATA[!($F{condition}]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="2e21f092-a95f-42b1-897e-50af56985554">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_label}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="a9fe6852-4253-4fb9-a089-d007459655dd">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="0" y="60" width="244" height="10" isRemoveLineWhenBlank="true" uuid="c102458f-d273-4611-a851-ed8e83adfead">
<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_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<printWhenExpression><![CDATA[!($F{condntion})]]></printWhenExpression>
</reportElement>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="100" height="10" uuid="80dcd916-f4c8-434d-a833-e864f64ddae5">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["field_label"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="100" y="0" width="144" height="10" uuid="5676615c-3ae5-41c6-8cf1-dbdef5cc3a99">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[$F{field_value}]]></textFieldExpression>
</textField>
</frame>
</frame>
</frame>
</band>
</detail>
In jasper reports you can not shrink elements, instead you need to stretch them when needed.
In your case this means that your frames in report needs to be at the minimum size you need, then if there is more content in them you stretch it.
For example, your first frame
<frame>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="0" width="554" height="71" isRemoveLineWhenBlank="true" uuid="603f6666-1471-4d16-b0aa-bde352f18b8e">
......
it will always have a minimum height of 71, if it it needs to be smaller (when some components are not displayed) you need to reduce this value to for example 10.
To explain this behavior, I will attach a small example, with a frame (that has a border) that contains 2 static text fields and the second one will display based on a parameter.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_3" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="53801704-697f-43ac-aed6-9e952be4ab7f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="ShowText2" class="java.lang.Boolean">
<defaultValueExpression><![CDATA[true]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="96" splitType="Stretch">
<frame>
<reportElement stretchType="ElementGroupHeight" x="0" y="0" width="545" height="30" uuid="6ca5ba0c-b9c0-4ae9-be7f-e7a372593e94"/>
<box>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="7291cb69-0d98-4ce2-8031-60b5c6df4ebb"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Static text 1]]></text>
</staticText>
<staticText>
<reportElement x="0" y="30" width="100" height="30" isRemoveLineWhenBlank="true" uuid="7df247c0-2c72-4413-83f5-3d4d3aec258c">
<printWhenExpression><![CDATA[$P{ShowText2}]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Static text 2]]></text>
</staticText>
</frame>
</band>
</title>
</jasperReport>
Output
Not displaying second text field
Displaying second text field
The key concept is that the frame has height="30" which is the not stretched value (minimum value) and instead it gets stretched to height="60" if the second text field is displayed.
Note: I'm using stretchType="ElementGroupHeight" since stretchType="RelativeToTallestObject" is deprecated.
Related
I'am using Jasper studio to generate pdf template. I added a table in this template without sources or database conenction but in jasper does not show the table. Below is my jrxml file:
<?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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="06cb70de-815a-4623-b868-91a92feca771">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Table_TH" mode="Opaque" backcolor="#549BDE">
<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="#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_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="d011bfa0-d2bd-475d-b7d1-4d69deec36be">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<subDataset name="Dataset2" uuid="563537d5-3b04-4cb9-93d6-4eb48c6fb5c7">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<subDataset name="Dataset3" uuid="fa68464d-99c7-4751-8e25-f173ce78f908">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<subDataset name="tableActiviteValide" uuid="bc90850c-a424-455b-8cb5-dd5df5282de5">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<parameter name="codeTournee" class="java.lang.String"/>
<parameter name="dateTournee" class="java.lang.String"/>
<parameter name="heureDepartTournee" class="java.lang.String"/>
<parameter name="heureDuPremierPoint" class="java.lang.String"/>
<parameter name="nbPointsPrevu" class="java.lang.String"/>
<parameter name="nomChauffeur" class="java.lang.String"/>
<parameter name="respectETA" class="java.lang.String"/>
<parameter name="statutTournee" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="51" splitType="Stretch">
<staticText>
<reportElement x="120" y="-16" width="320" height="66" uuid="240b4bfe-6b32-4a96-8bf1-69ba08f35e74"/>
<textElement textAlignment="Center">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Contôle retour collecte
Impression de la synthèse de l'activité]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="50" splitType="Stretch">
<textField>
<reportElement x="-16" y="10" width="237" height="40" uuid="9aa786c1-e331-4790-99cc-d509a0f8626c"/>
<textFieldExpression><![CDATA[new java.lang.String("Impression de ") + java.time.format.DateTimeFormatter.ofPattern("dd/MM/YYYY").format(java.time.LocalDate.now()) + new java.lang.String(" à ") + java.time.format.DateTimeFormatter.ofPattern("HH:mm").format(java.time.LocalTime.now())]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="220" splitType="Stretch">
<rectangle>
<reportElement x="10" y="20" width="535" height="190" uuid="58a48853-5a63-485a-8dd5-a4e3a36076c8"/>
<graphicElement>
<pen lineStyle="Solid"/>
</graphicElement>
</rectangle>
<staticText>
<reportElement x="30" y="48" width="60" height="20" uuid="ac6227f3-aa2c-4355-93c2-a3a67aacd2b1"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Tournée:]]></text>
</staticText>
<textField>
<reportElement x="169" y="48" width="60" height="20" uuid="3e0708e0-cc0f-4282-9e60-fa962be46bc9">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{codeTournee}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="30" y="80" width="60" height="20" uuid="a794c118-84d7-4f73-a87c-42366cc1d5fa"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Date:]]></text>
</staticText>
<staticText>
<reportElement x="30" y="110" width="120" height="20" uuid="fdfc42f2-30ca-4302-bb43-2e0b453cedf6"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Heure de départ:]]></text>
</staticText>
<staticText>
<reportElement x="30" y="140" width="136" height="20" uuid="f7abe915-02c3-4b85-839a-b528e4d7692b"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Heure du 1er point:]]></text>
</staticText>
<staticText>
<reportElement x="30" y="170" width="136" height="20" uuid="331e25b0-d0ef-461b-974b-f8a676b42505"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Nb points prévus:]]></text>
</staticText>
<textField>
<reportElement x="169" y="80" width="60" height="20" uuid="d75802b2-b117-4b79-9929-fe76fa8a594b">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$P{dateTournee}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="169" y="110" width="60" height="20" uuid="1264ce76-8691-4b1e-9fad-0bb2ec2b5780">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$P{heureDepartTournee}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="169" y="140" width="60" height="20" uuid="501a135a-f70c-4572-b9a1-becaada10c91">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$P{heureDuPremierPoint}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="169" y="170" width="60" height="20" uuid="6be68507-0e04-439a-a94e-3fb29c6b046f">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$P{nbPointsPrevu}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="300" y="48" width="60" height="20" uuid="d2e71c08-f045-4d9a-a478-eb2814ae58ab"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Nom:]]></text>
</staticText>
<textField>
<reportElement x="400" y="48" width="60" height="20" uuid="e8878870-3bcc-4237-8ba7-fb1eecd96482">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{nomChauffeur}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="300" y="140" width="90" height="20" uuid="91532fe1-2320-4f0f-ab7d-c69d98198911"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[RespectETA:]]></text>
</staticText>
<staticText>
<reportElement x="300" y="170" width="90" height="20" uuid="3e2d848e-9be5-47fb-aa9a-47c7634869fa"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Statut Tournée:]]></text>
</staticText>
<textField>
<reportElement x="400" y="140" width="60" height="20" uuid="92b863f7-011e-4a25-8e23-0d89066db13a">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{respectETA}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="400" y="170" width="60" height="20" uuid="9091a71f-fa56-413a-b0ed-31d57c34f1e9">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{respectETA}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="353" splitType="Stretch">
<staticText>
<reportElement x="10" y="4" width="534" height="66" uuid="8d8baf3e-51bf-436a-9691-dfda004dce54"/>
<text><![CDATA[Attention, les informations données à titre d'information pour permettre de mieux gérer l'activité sont susceptibles d'être modifiées à la suite du contrôle back-office, l'agence reste à votre disposition.]]></text>
</staticText>
<componentElement>
<reportElement x="20" y="80" width="311" height="85" uuid="52b7823f-9442-433e-b665-1398b400ae88">
<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="tableActiviteValide" uuid="5ac2165e-840c-4a99-9511-4bd1a604f544">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="40" uuid="ee0f7403-3157-4b14-aeaa-c8fb9dc5a97b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne1"/>
<jr:tableHeader style="Table_TH" height="60" rowSpan="2"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
<jr:column width="40" uuid="a9e963ba-1a80-4a5d-85b8-1d0d14e0ff05">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne2"/>
<jr:tableHeader style="Table_TH" height="60" rowSpan="2"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
<jr:column width="40" uuid="78afc7bc-a1f8-4fa8-aeac-311be51643c4">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne3"/>
<jr:tableHeader style="Table_TH" height="60" rowSpan="2"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
<jr:columnGroup width="80" uuid="7c6c7ce4-2a9a-4735-b4ce-55e99ff0379f">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonnes [2]"/>
<jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
<jr:column width="40" uuid="8033f192-d8fb-46f2-a87f-5acba54f6138">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne4"/>
<jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
<jr:column width="40" uuid="5f31f40c-f884-4ec1-a2f7-4cda37699e00">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne5"/>
<jr:tableHeader style="Table_TH" height="30" rowSpan="1"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
</jr:columnGroup>
<jr:column width="40" uuid="723c94fd-6ccc-4f10-b827-18477cc941fb">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne6"/>
<jr:tableHeader style="Table_TH" height="60" rowSpan="2"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
<jr:column width="40" uuid="4aea6eaf-a426-4be7-829a-a9b94c1b5777">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne7"/>
<jr:tableHeader style="Table_TH" height="60" rowSpan="2"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1"/>
<jr:columnFooter style="Table_CH" height="30" rowSpan="1"/>
<jr:detailCell style="Table_TD" height="30"/>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
There is no problem that had been shown in my report and the table is not visible in my template. How Can i resolve this?
Thank's!
You have to give some data to the table, otherwise jasper don't show it because nothing is to show when you give no data.
So I have a detail band with two frames, the first frame has several elements including a subreport, the second frame only has a textfield.
The issue I'm having is, if i remove the second frame from the band all the content remains in the same page. If i add the second frame and use the printonly expression to not show it, it changes the entire content to the next page.
Is there a way to force that, if the second frame is empty to maintain the behavior as if didn't exist at all?
<band height="160" splitType="Prevent">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<frame>
<reportElement isPrintRepeatedValues="false" x="0" y="1" width="556" height="116" isRemoveLineWhenBlank="true" uuid="3aca49ee-4b55-452c-a8c6-5cc252c4175c">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreport>
<reportElement positionType="Float" x="2" y="65" width="160" height="51" uuid="438d3f08-7b8a-4b61-b17f-19993aa5abe4">
<property name="local_mesure_unitx" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
</reportElement>
<subreportParameter name="DOC_ID">
<subreportParameterExpression><![CDATA[$P{DOC_ID}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="IS_RUNNING_LOCAL">
<subreportParameterExpression><![CDATA[$P{IS_RUNNING_LOCAL}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{IS_RUNNING_LOCAL} ? "/Reports/Common/xxxxxxxxxxxxxxSub.jasper" : "repo:/Reports/Common/xxxxxxxxxxxxxxSub"]]></subreportExpression>
</subreport>
<textField isStretchWithOverflow="true">
<reportElement style="Default" positionType="Float" mode="Transparent" x="1" y="1" width="552" height="30" isRemoveLineWhenBlank="true" forecolor="#000000" backcolor="#FFFFFF" uuid="837c85bf-7a2a-4eb5-919d-bd16d4bc64f2">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="local_mesure_unity" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
<property name="local_mesure_unitheight" value="pixel"/>
</reportElement>
<box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
<textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
<font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
</textElement>
<textFieldExpression><![CDATA["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="Default" positionType="Float" mode="Transparent" x="2" y="43" width="511" height="17" forecolor="#000000" backcolor="#FFFFFF" uuid="3e1c3952-6578-4d5f-85a3-d706fc5a5fbb">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitx" value="cm"/>
<property name="com.jaspersoft.studio.unit.x" value="cm"/>
<property name="local_mesure_unitheight" value="pixel"/>
</reportElement>
<box padding="0" topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/>
<textElement textAlignment="Justified" verticalAlignment="Top" rotation="None" markup="html">
<font fontName="Arial" size="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
<paragraph lineSpacing="Single" lineSpacingSize="1.0" firstLineIndent="0" leftIndent="0" rightIndent="0" spacingBefore="0" spacingAfter="0" tabStopWidth="40"/>
</textElement>
<textFieldExpression><![CDATA["testetestestestestestes"]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement positionType="Float" x="1" y="120" width="555" height="40" isRemoveLineWhenBlank="true" uuid="c3bf96ce-dd19-41f1-bf13-fe1dd46d8d4e">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
<textField isBlankWhenNull="true">
<reportElement positionType="Float" isPrintRepeatedValues="false" mode="Transparent" x="1" y="0" width="551" height="39" isRemoveLineWhenBlank="true" uuid="c1ab35b8-31a6-41e9-a260-71bbcab8692e">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Justified">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA["PS: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]]></textFieldExpression>
</textField>
</frame>
</band>
Is there a way to force that, if the second frame is empty to maintain the behavior as if didn't exist at all?
The solution to this is to use multiple detail bands and set the printWhenExpression to the detail band
<?xml version="1.0" encoding="UTF-8"?>
<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="TestParams" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f85bc6aa-5060-4485-bd99-bd5de1734ef1">
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="116">
<break>
<reportElement x="0" y="5" width="100" height="1" uuid="fb9c89cd-1b6a-44f5-82a9-99e9996229e3">
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
</reportElement>
</break>
<frame>
<reportElement x="0" y="10" width="200" height="116" uuid="e6890adf-6ff1-49f6-9c47-ba6f171a2c60"/>
</frame>
</band>
<band height="40">
<printWhenExpression><![CDATA[$P{COD_DOC}.equals("xx_xxx_xxx")]]></printWhenExpression>
<frame>
<reportElement x="0" y="0" width="200" height="40" uuid="d9f8ba4a-e435-49ff-9ff7-d23e55aecc52"/>
</frame>
</band>
</detail>
</jasperReport>
This way if second component is not showing/printed the whole band (height) will be removed and it will behave as only first band exists.
I have a jasper report that looks like a certificate.
I have a background image that serves as the attractive bordering or frame of the whole page.
The problem is, if for example, the name in text field is much bigger than the element container, it creates extra white space in the bottom.
The background image / frame is not stretching to stretch the the whole edges of the page.
The same is true when the text fields are shorter. But in this case, the page is shortened to the point that you almost cannot see the bottom portion of the frame.
I want the image to dynamically stretch depending on the final size of the page at runtime.
Here is the look of my design:
This is what happens when it is compiled, as you can see there are extra white spaces at the bottom:
This is the current setting of my image..
Position Type: Float
Stretch Type: ContainerBottom
The jrxml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="paiwi-certificate-pdf" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="792" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isIgnorePagination="true" uuid="28bcb6f8-04d6-48df-ab31-e1bedc2f2434">
<property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String"/>
<parameter name="farmContactListSubreportDataSource" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="farmName" class="java.lang.String"/>
<parameter name="farmLogo" class="java.lang.String"/>
<parameter name="farmAddress" class="java.lang.String"/>
<parameter name="farmBusinessAddress" class="java.lang.String"/>
<parameter name="temporaryPartnersName" class="java.lang.String"/>
<parameter name="partnerName" class="java.lang.String"/>
<parameter name="partnerContactNumber" class="java.lang.String"/>
<parameter name="partnerEmail" class="java.lang.String"/>
<parameter name="packageName" class="java.lang.String"/>
<parameter name="batchName" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
<detail>
<band height="612" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<staticText>
<reportElement positionType="Float" x="146" y="80" width="224" height="40" forecolor="#332411" uuid="cb95bd0b-631e-4363-80f5-22d0b0e481fe">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false"/>
</textElement>
<text><![CDATA[CERTIFICATE]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="372" width="446" height="28" uuid="6281f2a7-4eca-4319-b298-22184617a6d3">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="24" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmName}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="400" width="446" height="17" uuid="f19dc14b-3ada-460b-8633-85fd5a896d45">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmAddress}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="50" y="417" width="446" height="17" uuid="dec9944a-2758-4202-acfe-6f97df346b8f">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{farmBusinessAddress}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="164" y="180" width="473" height="40" forecolor="#332411" uuid="b2a59bb8-1557-498f-b17a-3f0e561bb11b">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="37" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{partnerName} != null && !$P{partnerName}.equalsIgnoreCase("") ? $P{partnerName} : $P{temporaryPartnersName}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement positionType="Float" x="569" y="338" width="164" height="160" uuid="717d6475-3d42-4e54-a69a-7271bc862e33"/>
<imageExpression><![CDATA[$P{farmLogo}]]></imageExpression>
</image>
<staticText>
<reportElement positionType="Float" x="416" y="81" width="228" height="40" forecolor="#332411" uuid="f2a78f2d-ed74-45b9-89e8-3365c4afe801">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false"/>
</textElement>
<text><![CDATA[COMPLETION]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="378" y="80" width="33" height="40" forecolor="#332411" uuid="e1c7ac87-81ce-4e8d-b718-2aee4f139003"/>
<textElement markup="none">
<font fontName="Georgia" size="34" isBold="false" isItalic="true"/>
</textElement>
<text><![CDATA[of]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="311" y="148" width="179" height="15" forecolor="#6E6E6E" uuid="3d5afae8-14e2-4a3b-8471-db8388e2309f">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[THIS ACKNOWLEDGES THAT]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="290" y="249" width="232" height="15" forecolor="#6E6E6E" uuid="4c301efe-c460-478e-873a-d16430000b18">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[HAS SUCCESSFULLY COMPLETED THE]]></text>
</staticText>
<staticText>
<reportElement positionType="Float" x="50" y="357" width="232" height="15" forecolor="#6E6E6E" uuid="1060f753-1051-4925-9efe-c2ee62146b25">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement markup="none">
<font fontName="Verdana" size="12" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[ACKNOWLEDGED BY:]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="275" y="279" width="263" height="17" uuid="3ab3ec94-b64f-42df-b475-7996bcac1abb">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{packageName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="359" y="296" width="43" height="16" forecolor="#000000" uuid="c6e10785-2750-4247-af0c-6cbafa3aa294"/>
<textElement markup="none">
<font fontName="Georgia" size="14" isBold="false"/>
<paragraph lineSpacingSize="1.0"/>
</textElement>
<text><![CDATA[Batch:]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" x="402" y="296" width="48" height="16" forecolor="#000000" uuid="dff76163-3fd3-4bf6-94fd-de4612485e29">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Georgia" size="14" isBold="false" isUnderline="false"/>
</textElement>
<textFieldExpression><![CDATA[$P{batchName}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement positionType="Float" x="140" y="279" width="126" height="30" uuid="b0c2acd4-1a0c-4fe6-9a94-be43fe67d704"/>
<imageExpression><![CDATA["https://i.imgur.com/Ug4T4oX.png"]]></imageExpression>
</image>
<image onErrorType="Blank">
<reportElement positionType="Float" x="550" y="279" width="126" height="30" uuid="9d2cddda-e519-42e2-b74b-554f4c102ef2"/>
<imageExpression><![CDATA["https://i.imgur.com/paQHNxJ.png"]]></imageExpression>
</image>
<image scaleImage="RetainShape" vAlign="Bottom" onErrorType="Blank" evaluationTime="Page">
<reportElement positionType="Float" stretchType="ContainerBottom" x="0" y="0" width="782" height="612" isPrintInFirstWholeBand="true" uuid="2dadd1da-0694-4e21-86de-fae790844411">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["https://i.imgur.com/y8uffu8.png"]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
I think your only problem is that you do not have the correct scaleImage property set, hence the element is actually resizing but since you have scaleImage="RetainShape" the image will not fill the new element dimension but instead maintain orignal image proportions
From Jasper Reports Ultimate guide:
Clipping the image: If the actual image is larger than the image element size, it will be cut off so that it keeps its original
resolution, and only the region that fits the specified size will be
displayed (scaleImage="Clip").
Forcing the image size: If the dimensions of the actual image do not fit those specified for the image element that displays it, the image
is forced to obey them and stretch itself so that it fits in the
designated output area. It will be deformed if necessary
(scaleImage="FillFrame").
Keeping the image proportions: If the actual image does not fit into the image element, it can be adapted to those dimensions while
keeping its original undeformed proportions
(scaleImage="RetainShape").
Stretching the image keeping the width: The image can be stretched vertically to match the actual image height, while preserving the
declared width of the image element (scaleImage="RealHeight").
Stretching the image adjusting the width: The image can be stretched vertically to match the actual image height, while adjusting
the width of the image element to match the actual image width
(scaleImage="RealSize").
So you need:
scaleImage="FillFrame"
something like this
<image scaleImage="FillFrame" vAlign="Bottom" onErrorType="Blank">
<reportElement stretchType="ContainerHeight" x="10" y="0" width="782" height="612" uuid="2dadd1da-0694-4e21-86de-fae790844411">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["https://i.imgur.com/y8uffu8.png"]]></imageExpression>
</image>
I have a simple Spring-based web application for reporting about measurement tools. I'm using the following JRXML pattern (generated by TIBCO Jaspersoft Studio), let's say report_3.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="polviz" class="java.lang.String"/>
<field name="polzex" class="java.lang.String"/>
<field name="polnaim" class="java.lang.String"/>
<field name="tip" class="java.lang.String"/>
<field name="klt" class="java.lang.Double"/>
<field name="pred" class="java.lang.String"/>
<field name="zavn" class="java.lang.String"/>
<field name="npasp" class="java.lang.Integer"/>
<field name="pp" class="java.lang.Integer"/>
<field name="n" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="84">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<staticText>
<reportElement x="410" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[УТВЕРЖДАЮ]]></text>
</staticText>
<staticText>
<reportElement x="410" y="14" width="100" height="20" />
<text><![CDATA[Главный метролог]]></text>
</staticText>
<line>
<reportElement x="410" y="39" width="120" height="1" />
</line>
<staticText>
<reportElement x="410" y="39" width="140" height="30" />
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[(подпись, расшифровка подписи, дата)]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="85" splitType="Stretch">
<staticText>
<reportElement positionType="FixRelativeToBottom" x="-2" y="0" width="559" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman"/>
</textElement>
<text><![CDATA[Общая ведомость средств измерений по цехам]]></text>
</staticText>
<line>
<reportElement x="0" y="83" width="554" height="1" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="0" y="66" width="554" height="16" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polviz}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="52" width="552" height="14" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isItalic="false"/>
</textElement>
<text><![CDATA[/ N - не проверено, R - ремонт, К - консервация /]]></text>
</staticText>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="1" y="30" width="552" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polzex}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="34" splitType="Stretch">
<staticText>
<reportElement x="1" y="1" width="110" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Наим. средства изм.]]></text>
</staticText>
<staticText>
<reportElement x="110" y="1" width="50" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Тип]]></text>
</staticText>
<staticText>
<reportElement x="160" y="1" width="68" height="30" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Предел изм.]]></text>
</staticText>
<staticText>
<reportElement x="280" y="1" width="78" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Зав. ном.]]></text>
</staticText>
<line>
<reportElement x="0" y="32" width="554" height="1" />
</line>
<line>
<reportElement x="0" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="109" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="159" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="228" y="-2" width="1" height="34" />
</line>
<line>
<reportElement x="359" y="-2" width="1" height="34" />
</line>
<staticText>
<reportElement x="360" y="1" width="74" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Ном. пасп.]]></text>
</staticText>
<line>
<reportElement x="434" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="436" y="0" width="54" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Периодич.]]></text>
</staticText>
<line>
<reportElement x="490" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="490" y="0" width="62" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Неп,Рем,Конс]]></text>
</staticText>
<line>
<reportElement x="554" y="-1" width="1" height="33" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="230" y="1" width="46" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Кл.т.]]></text>
</staticText>
<line>
<reportElement x="277" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="33">
<line>
<reportElement x="1" y="19" width="553" height="1" forecolor="#E5E5E5" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement x="2" y="1" width="108" height="18" />
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{polnaim}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="111" y="1" width="50" height="18" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{tip}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="161" y="1" width="68" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pred}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="1" width="48" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{klt}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="1" width="82" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zavn}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="360" y="1" width="76" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{npasp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="1" width="56" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="492" y="1" width="62" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{n}]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
Part of JasperReportsController controller:
...
#Controller
#RequestMapping("/jasper-reports/")
public class JasperReportsController {
#Autowired(required = true)
private MetrologServices metrologServices;
#Autowired
private ApplicationContext appContext;
#RequestMapping(method = RequestMethod.GET, value = "report_3")
public ModelAndView generateThirdPdfReport(ModelAndView modelAndView) {
JasperReportsPdfView jrPdfView = new JasperReportsPdfView();
List<ReportDTO> records = findInventoryReportData();
Map<String, Object> map = new HashMap<String, Object>();
map.put("records", records);
jrPdfView.setUrl("classpath:report_3.jrxml");
jrPdfView.setReportDataKey("records");
jrPdfView.setApplicationContext(appContext);
modelAndView = new ModelAndView(jrPdfView, map);
return modelAndView;
}
private List<ReportDTO> findInventoryReportData() {
List<ReportDTO> result = metrologServices.loadInventoryData();
return result;
}
...
}
Somewhere in the view I call the controller:
$("#btn-print").attr("href", "${home}/metrolog/jasper-reports/report_3");
As a result I get the following report:
I want to start the list of measurement tools for each department with a new page. For example, part of the measuring tools belongs to department 1, another part belongs to department 2, etc.
I'd advise the following documentation: Chapter 14. View technologies, see section "14.7.4. Working with Sub-Reports":
JasperReports provides support for embedded sub-reports within your
master report files. There are a wide variety of mechanisms for
including sub-reports in your report files. The easiest way is to hard
code the report path and the SQL query for the sub report into your
design files. The drawback of this approach is obvious - the values
are hard-coded into your report files reducing reusability and making
it harder to modify and update report designs. To overcome this you
can configure sub-reports declaratively and you can include additional
data for these sub-reports directly from your controllers.
To control which sub-report files are included in a master report
using Spring, your report file must be configured to accept
sub-reports from an external source. To do this you declare a
parameter in your report file like so:
<parameter name="ProductsSubReport" class="net.sf.jasperreports.engine.JasperReport"/>
Then, you define your sub-report to use this sub-report parameter:
<subreport>
<reportElement isPrintRepeatedValues="false" x="5" y="25" width="325"
height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/>
<subreportParameter name="City">
<subreportParameterExpression><![CDATA[$F{city}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{ProductsSubReport}]]></subreportExpression>
</subreport>
This defines a master report file that expects the sub-report to be
passed in as an instance of
net.sf.jasperreports.engine.JasperReports under the parameter
ProductsSubReport. When configuring your Jasper view class, you can
instruct Spring to load a report file and pass into the JasperReports
engine as a sub-report using the subReportUrls property:
<property name="subReportUrls">
<map>
<entry key="ProductsSubReport" value="/WEB-INF/reports/subReportChild.jrxml"/>
</map>
</property>
Here, the key of the Map corresponds to the name of the sub-report
parameter in th report design file, and the entry is the URL of the
report file. Spring will load this report file, compiling it if
necessary, and will pass into the JasperReports engine under the given
key.
Hence, the master report file can be represented as follows:
report_3.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<parameter name="Kpp9SubReport" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="Kpp9SubReportData" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="..." class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="..." class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
...
etc
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="84">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<staticText>
<reportElement x="410" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[УТВЕРЖДАЮ]]></text>
</staticText>
<staticText>
<reportElement x="410" y="14" width="100" height="20" />
<text><![CDATA[Главный метролог]]></text>
</staticText>
<line>
<reportElement x="410" y="39" width="120" height="1" />
</line>
<staticText>
<reportElement x="410" y="39" width="140" height="30" />
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[(подпись, расшифровка подписи, дата)]]></text>
</staticText>
</band>
</title>
<detail>
<band height="500">
<subreport>
<reportElement isPrintRepeatedValues="false" x="-10" y="0" width="325" height="1" isRemoveLineWhenBlank="false" backcolor="#ffcc99"/>
<dataSourceExpression><![CDATA[$P{DepartmentKpp9SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{DepartmentKpp9SubReport}]]></subreportExpression>
</subreport>
<break type="Page">
<reportElement x="-10" y="1" width="325" height="10" key="element-1"/>
</break>
</band>
<band height="500">
<subreport>
<reportElement isPrintRepeatedValues="false" x="-10" y="2" width="325" height="1" isRemoveLineWhenBlank="false" backcolor="#ffcc99"/>
<dataSourceExpression><![CDATA[$P{Department8SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{Department8SubReport}]]></subreportExpression>
</subreport>
<break type="Page">
<reportElement x="-10" y="3" width="325" height="1" key="element-2"/>
</break>
</band>
<band height="500">
...
</band>
...
etc
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
The sub-report report_4.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<field name="polviz" class="java.lang.String"/>
<field name="polzex" class="java.lang.String"/>
<field name="polnaim" class="java.lang.String"/>
<field name="tip" class="java.lang.String"/>
<field name="klt" class="java.lang.Double"/>
<field name="pred" class="java.lang.String"/>
<field name="zavn" class="java.lang.String"/>
<field name="npasp" class="java.lang.Integer"/>
<field name="pp" class="java.lang.Integer"/>
<field name="n" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="85" splitType="Stretch">
<staticText>
<reportElement positionType="FixRelativeToBottom" x="-2" y="0" width="559" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman"/>
</textElement>
<text><![CDATA[Общая ведомость средств измерений по цехам]]></text>
</staticText>
<line>
<reportElement x="0" y="83" width="554" height="1" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="0" y="66" width="554" height="16" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polviz}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="52" width="552" height="14" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isItalic="false"/>
</textElement>
<text><![CDATA[/ N - не проверено, R - ремонт, К - консервация /]]></text>
</staticText>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="1" y="30" width="552" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polzex}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="34" splitType="Stretch">
<staticText>
<reportElement x="1" y="1" width="110" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Наим. средства изм.]]></text>
</staticText>
<staticText>
<reportElement x="110" y="1" width="50" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Тип]]></text>
</staticText>
<staticText>
<reportElement x="160" y="1" width="68" height="30" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Предел изм.]]></text>
</staticText>
<staticText>
<reportElement x="280" y="1" width="78" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Зав. ном.]]></text>
</staticText>
<line>
<reportElement x="0" y="32" width="554" height="1" />
</line>
<line>
<reportElement x="0" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="109" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="159" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="228" y="-2" width="1" height="34" />
</line>
<line>
<reportElement x="359" y="-2" width="1" height="34" />
</line>
<staticText>
<reportElement x="360" y="1" width="74" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Ном. пасп.]]></text>
</staticText>
<line>
<reportElement x="434" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="436" y="0" width="54" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Периодич.]]></text>
</staticText>
<line>
<reportElement x="490" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="490" y="0" width="62" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Неп,Рем,Конс]]></text>
</staticText>
<line>
<reportElement x="554" y="-1" width="1" height="33" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="230" y="1" width="46" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Кл.т.]]></text>
</staticText>
<line>
<reportElement x="277" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="33">
<line>
<reportElement x="1" y="19" width="553" height="1" forecolor="#E5E5E5" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement x="2" y="1" width="108" height="18" />
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{polnaim}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="111" y="1" width="50" height="18" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{tip}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="161" y="1" width="68" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pred}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="1" width="48" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{klt}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="1" width="82" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zavn}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="360" y="1" width="76" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{npasp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="1" width="56" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="492" y="1" width="62" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{n}]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
Part of JasperReportsController controller(we consider only the case of one department, the other sub-reports can be obtained similarly using the same templates report_3.jrxml and report_4.jrxml):
...
#Controller
#RequestMapping("/jasper-reports/")
public class JasperReportsController {
#Autowired(required = true)
private MetrologServices metrologServices;
#Autowired
private ApplicationContext appContext;
#RequestMapping(method = RequestMethod.GET, value="report_3")
public ModelAndView generateThirdPdfReport(ModelAndView modelAndView) {
JasperReportsPdfView jrPdfView = new JasperReportsPdfView();
List<ReportDTO> records = findInventoryReportData();
Map<String, Object> map = new HashMap<>();
map.put("records", records);
Properties subReports = new Properties();
subReports.put("Kpp9SubReport", "classpath:report_4.jrxml");
List<ReportDTO> kpp9SubReportRecords = new ArrayList<>();
records.forEach(record -> {
if(record.getPolzex().equalsIgnoreCase("КПП 9")) {
kpp9SubReportRecords.add(record);
}
});
JRDataSource kpp9SubReportDataSource =
new JRBeanCollectionDataSource(kpp9SubReportRecords);
parameterMap.put("Kpp9SubReportData", kpp9SubReportDataSource);
jrPdfView.setSubReportUrls(subReports);
jrPdfView.setSubReportDataKeys("Kpp9SubReportData");
jrPdfView.setUrl("classpath:report_3.jrxml");
jrPdfView.setReportDataKey("records");
jrPdfView.setApplicationContext(appContext);
modelAndView = new ModelAndView(jrPdfView, map);
return modelAndView;
}
private List<ReportDTO> findInventoryReportData() {
List<ReportDTO> result = metrologServices.loadInventoryData();
return result;
}
...
}
As a result, we getting such a report, as required(in the department there are only five measuring instruments):
I'm building a report using iReport and Jasper Reports 4.5.0. Everything it's working fine except that I have a requirement, in the formatting of some tables that I can't resolve yet.
There are some columns which need to have title (grouping two or more columns) and subtitle (for each one), and I can't figure out how to accomplish this.
Here is an example of the final "style" needed:
| POSITION |column 2|column 3|
| x | Y | | |
------------------------------
| 10 | 20 |value|value
I think you are over thinking this. If you are not using Grouping on the data, which based on your example, it does not appear you do, then this is pretty basic.
Column headers are nothing but static text fields. and you can add them where ever you want in the Column Header band. Here is a stubbed out example of the JRXML so you can see what I mean.
<?xml version="1.0" encoding="UTF-8"?>
<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="report1" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b478862e-b118-4290-8664-eae9b2966b31">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="GROUP_BY" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<field name="x" class="java.lang.String"/>
<field name="y" class="java.lang.String"/>
<field name="column1" class="java.lang.String"/>
<field name="column2" class="java.lang.String"/>
<columnHeader>
<band height="40" splitType="Stretch">
<staticText>
<reportElement uuid="039d11f3-52eb-4717-9c83-34cbdcb81d6a" x="0" y="20" width="100" height="20"/>
<textElement/>
<text><![CDATA[x]]></text>
</staticText>
<staticText>
<reportElement uuid="f0d66af8-19c2-4d50-9d1a-37b1162a75a8" x="100" y="20" width="100" height="20"/>
<textElement/>
<text><![CDATA[y]]></text>
</staticText>
<staticText>
<reportElement uuid="44e3960a-31f3-444c-ad32-061af30cf82c" x="200" y="0" width="100" height="20"/>
<textElement/>
<text><![CDATA[column1]]></text>
</staticText>
<staticText>
<reportElement uuid="6d468249-5242-4cf6-a4db-7995bdea15ba" x="300" y="1" width="100" height="20"/>
<textElement/>
<text><![CDATA[column2]]></text>
</staticText>
<staticText>
<reportElement uuid="461dc8bb-a938-42ed-86c5-006732fbba4f" x="0" y="0" width="200" height="20"/>
<textElement/>
<text><![CDATA[Position]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="23" splitType="Stretch">
<textField>
<reportElement uuid="e2aff92b-0f47-4f78-9f49-c861c04533be" x="0" y="3" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{x}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="6091fb48-0bb6-422e-8520-b6e2d6e5cce1" x="100" y="3" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{y}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8b32925f-256c-4026-a3f1-8e435a12ccd0" x="200" y="3" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{column1}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="8b9d0540-da1a-41bf-b7e8-5f2cf9141fb6" x="300" y="3" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{column2}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
I was able to get multi-line column-headers with a multi-page report with the following procedure:
Set the Column Header height for table to 40px
Columns 1 & 2 had a one-line header, so these had text boxes of height=40px
code below contains xml for column 1 "Gathering System" but column 2 left out for readability)
I Grouped columns 3-5
columnGroup width="240"
columnHeader height="40"
textbox1 "Allocated Production": x="0" y="0" width="240" height="20"
textbox2 "Gas MCF": x="0" y="20" width="80" height="20"
textbox3 "Oil": x="80" y="20" width="80" height="20"
textbox3 "Water": x="160" y="20" width="80" height="20"
Column 1
<jr:column width="200" uuid="5255e943-4959-49c4-9f83-0c6567d56684">
<jr:groupFooter groupName="GatheringGroup_dsSixMonths">
<jr:cell style="Alternate_Row" height="20" rowSpan="1">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<textField isStretchWithOverflow="true" pattern="#,##0.00">
<reportElement x="0" y="0" width="200" height="20" uuid="78a4370a-8d3e-4bae-9a58-47b5b947189c"/>
<textFieldExpression><![CDATA[$F{GatheringSystem.GatheringSystemName}]]></textFieldExpression>
</textField>
</jr:cell>
</jr:groupFooter>
<jr:columnHeader height="40" rowSpan="1">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<staticText>
<reportElement style="Crosstab_Header" x="0" y="0" width="200" height="40" uuid="9b4976a1-5deb-4edf-a4a7-39bd4375663d">
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<text><![CDATA[Gathering System]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="0">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
</jr:detailCell>
</jr:column>
Cols 3-5 - COLUMN GROUP HAS width="240" pixels
<jr:columnGroup width="240" uuid="dc55dcaa-91d3-4450-9300-3aaea94c789a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [3]"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<jr:columnHeader style="Table 1_CH" height="40">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
First text box "Allocated Production" has height="20"px, width="240"
<staticText>
<reportElement style="Crosstab_Header" x="0" y="0" width="240" height="20" uuid="1308d33c-05c3-4a0b-8fb3-6247693a95b6">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<text><![CDATA[Allocated Production]]></text>
</staticText>
Second text box "Gas MCF" has height="20"px, width="80", positioned at x=0, y=20
<staticText>
<reportElement style="Crosstab_Header" x="0" y="20" width="80" height="20" uuid="3b3cacbb-232c-4a5c-afd7-e069213d6eac">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<text><![CDATA[Gas MCF]]></text>
</staticText>
Third text box "Oil" is positioned at x=80, y=20
<staticText>
<reportElement style="Crosstab_Header" x="80" y="20" width="80" height="20" uuid="6fd8d11e-b10c-4530-aaa7-2b2066ddc1de">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<text><![CDATA[Oil]]></text>
</staticText>
Last text box "Water" is positioned at x=160, y=20
<staticText>
<reportElement style="Crosstab_Header" x="160" y="20" width="80" height="20" uuid="4402b753-1d83-4e19-9467-47c6d5d7b173">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
</reportElement>
<text><![CDATA[Water]]></text>
</staticText>
</jr:columnHeader>
I was having the same trouble but was using a Table Component and needed that the first column didn't showed up if there aren't any rows (with the Column Header approach didn't work as I wanted)
So I solved this problem using columnGroup to wrap all the columns I needed (in your example, POSITION columns) setting to 0 the height of the rows I didn't want to show (in the example JRXML portion below you'll see it between the columnGroup tags for tableFooter, columnHeader and columnFooter)
The example below is a table component that results in something like this
+-------------------+
| POSITION |
+-------------------+---------------+---------------+
| x | y | Column1 | Column2 |
+---------+---------+---------------+---------------+
| $F{x} | $F{Y} | $F{column1} | $F{column2} |
+-------------------+---------------+---------------+
JRXML code:
<componentElement>
<reportElement x="0" y="0" width="555" height="100" uuid="b3ffd7ef-3e0f-48be-8405-545f6c9cd313"/>
<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="YOURTABLEDATASET" uuid="5f5f5dc3-96fa-40a7-b9ce-0741bf321af6">
<connectionExpression>YOURCONNECTIONORDATASOURCE</connectionExpression>
</datasetRun>
<jr:columnGroup width="340" uuid="10695d6d-0223-4bf7-93e0-82d8ff720988">
<property name="local_mesure_unitheight" value="pixel"/>
<jr:tableHeader height="40">
<staticText>
<reportElement x="0" y="0" width="340" height="40" uuid="708fab06-2d51-4e70-b17a-4c3b30ebf188"/>
<textElement verticalAlignment="Bottom"/>
<text><![CDATA[POSITION]]></text>
</staticText>
</jr:tableHeader>
<jr:tableFooter height="0"/>
<jr:columnHeader height="0"/>
<jr:columnFooter height="0"/>
<jr:column width="170" uuid="80cd4d4e-f92d-4144-8f03-1fdf8662d52f">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="170" height="30" uuid="ae24719f-dd68-41d8-9e1f-fffb458309d0"/>
<text><![CDATA[x]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="170" height="30" uuid="53731196-ea6f-4378-b99a-22ee9f9ea4ba"/>
<textFieldExpression><![CDATA[$F{x}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="170" uuid="ae1bfc2b-69c6-422e-8db0-150ec8d66973">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="170" height="30" uuid="93c5f52e-67d6-40c9-afd8-1e867104d9b0"/>
<text><![CDATA[y]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="170" height="30" uuid="60320299-d2fa-46d6-87c0-25dbe7b14d92"/>
<textFieldExpression><![CDATA[$F{y}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
<jr:column width="100" uuid="a2eed3c8-5862-4026-b5b3-dd516f850b44">
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="9b694559-1a3d-4e68-abfe-7cd95ad447de"/>
<text><![CDATA[column1]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="6c22c7d4-dde9-42f7-8564-a229e235a186"/>
<textFieldExpression><![CDATA[$F{column1}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="100" uuid="d57153ea-a883-4b2e-b351-b0950f4aae0d">
<property name="local_mesure_unitwidth" value="pixel"/>
<jr:columnHeader height="30">
<staticText>
<reportElement x="0" y="0" width="100" height="30" uuid="e64920ab-19de-4108-a63b-fea1484b5ba3"/>
<text><![CDATA[column2]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30">
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="bfafd138-ed50-4fb4-91f4-61df26ab66fa"/>
<textFieldExpression><![CDATA[$F{column2}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>