I have created a report within the jrxml. I have specified to only print the details of each value if one of my fields is populated using the tag <printWhenExpression>
with a value like so:
<textField>
<reportElement x="670" y="4" width="105" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
This works in filtering only relevant data, however it leaves me with a lot of blank rows within the report. I have enabled the condition isRemoveLineWhenBlank="true"
to remove these blank rows from being displayed on my report. This has taken my report from 12 pages to 5, however, I still observe a large number of empty rows within the report.
Here is a ScreenShot of my reports design in ireport.
And here is a ScreenShot of the report run (I've blanked out my company's name from the classes)
The full report 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="RIOBridgeReport" pageWidth="1530" pageHeight="842" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="10" rightMargin="5" topMargin="10" bottomMargin="10">
<property name="ireport.zoom" value="2.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1" value="columnHeader"/>
<parameter name="title" class="java.lang.String"/>
<parameter name="oneliner" class="java.lang.String"/>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[id[starts-with(.,'USCS')]]]></fieldDescription>
</field>
<field name="class" class="java.lang.String">
<fieldDescription><![CDATA[class]]></fieldDescription>
</field>
<field name="value" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg/value]]></fieldDescription>
</field>
<field name="value1" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg[1]/value]]></fieldDescription>
</field>
<field name="value2" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg[2]/value]]></fieldDescription>
</field>
<variable name="runDate" class="java.lang.String">
<initialValueExpression><![CDATA[new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z").format(new java.util.Date())]]></initialValueExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="53" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="12" y="12" width="496" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{title} + " - " + $V{runDate}]]></textFieldExpression>
</textField>
<image>
<reportElement x="616" y="0" width="84" height="53"/>
<imageExpression><![CDATA["citi_corp_logo.gif"]]></imageExpression>
</image>
<textField isBlankWhenNull="true">
<reportElement x="12" y="32" width="496" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{oneliner}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement x="12" y="2" width="85" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Bean Name]]></text>
</staticText>
<staticText>
<reportElement x="228" y="2" width="85" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Class]]></text>
</staticText>
<staticText>
<reportElement x="428" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value]]></text>
</staticText>
<staticText>
<reportElement x="543" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value1]]></text>
</staticText>
<staticText>
<reportElement x="670" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value2]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="24">
<textField isBlankWhenNull="true">
<reportElement x="12" y="2" width="216" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="228" y="2" width="185" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{class}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="428" y="2" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="543" y="4" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="670" y="4" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
</textField>
</band>
</detail>
<noData>
<band height="20">
<staticText>
<reportElement x="146" y="0" width="200" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="14" isBold="true"/>
</textElement>
<text><![CDATA[No data found]]></text>
</staticText>
</band>
</noData>
</jasperReport>
As you can see still a large amount of whitespace left within the report. Is there a way to completely remove them or push the blank rows to the end of the report.
Try placing everything inside a frame and add the "Remove line when blank" to the frame.
Instead of isRemoveLineWhenBlank for a field use the band properties of detail band. Therefore this condition should be put in the detail band properties printWhenExpression. .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With