我在 jrxml 中创建了一个报告。我已指定仅在使用具有如下值的标签填充我的一个字段时打印每个值的详细信息<printWhenExpression>
:
<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>
这仅适用于过滤相关数据,但是它在报告中留下了很多空白行。我已启用条件isRemoveLineWhenBlank="true"
以删除这些空白行,使其不再显示在我的报告中。这使我的报告从 12 页减少到 5 页,但是,我仍然在报告中观察到大量空行。
这是我在 ireport 中的报告设计的屏幕截图。
这是报告运行的屏幕截图(我已经从课程中删除了我公司的名称)
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>
如您所见,报告中仍有大量空白。有没有办法完全删除它们或将空白行推到报告的末尾。