如何在 Jasper Reports 中动态地进行分页?
How to do pagination dynamically in Jasper Reports?
我对 jasper 报告还很陌生,
我想做的是,我想每页获取 1000 条记录,因此为此我使用 Jaspersoft Studio 并通过提供 Print When Expression as $V{ 在详细信息带中使用 break 元素PAGE_COUNT} == 1000 而且我已经将页面高度拉伸到可以容纳 1000 条记录的某个点。所以到这里一切都很好,但问题是如果我得到总计 1200 条记录,那么它会在第一页显示 1000 条记录,但在第二页只显示 200 条记录,留下 800 行空 space,这是不被接受的客户。我想要的是,如果第二页只有 200 行,则应通过消除那些空 spaces.
来动态调整页脚
添加相应的 .jrxml 代码。因此,非常感谢任何人的帮助,在此先感谢。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<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="BluePrint" pageWidth="1050" pageHeight="58270" columnWidth="1010" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="554b0f60-56e2-48fb-ab4b-782b23ffc73e">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter(ATT Dev DS)"/>
<parameter name="Manufacturer" class="java.lang.String"/>
<queryString language="SQL">
<![CDATA[select id, inserted, manufacturer, model, model_id, supported_protocols, os
from DEVICE_MODEL_CONFIG dm
WHERE DM.MANUFACTURER = $P{Manufacturer}]]>
</queryString>
<field name="ID" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="ID"/>
</field>
<field name="INSERTED" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="INSERTED"/>
</field>
<field name="MANUFACTURER" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="MANUFACTURER"/>
</field>
<field name="MODEL" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="MODEL"/>
</field>
<field name="MODEL_ID" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="MODEL_ID"/>
</field>
<field name="SUPPORTED_PROTOCOLS" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SUPPORTED_PROTOCOLS"/>
</field>
<field name="OS" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="OS"/>
</field>
<title>
<band height="151" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="-20" y="-20" width="1050" height="149" backcolor="#006699" uuid="f7182fe6-ad8d-458d-87db-0a9956733132"/>
<staticText>
<reportElement x="19" y="10" width="580" height="49" uuid="55c262d1-3e27-41ae-b5aa-621651bb240d"/>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="Times New Roman" size="35" isBold="true"/>
</textElement>
<text><![CDATA[DeviceModelByManufacturer]]></text>
</staticText>
<textField>
<reportElement x="154" y="100" width="200" height="30" uuid="c6f91dac-00d6-4417-a74d-3ed27f2048b6">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement textAlignment="Left">
<font size="16" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Manufacturer}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="23" y="72" width="191" height="31" uuid="bfab0c72-c839-4df0-9c3a-b782435f0d2e"/>
<textElement>
<font fontName="Times New Roman" size="18" isBold="true"/>
</textElement>
<text><![CDATA[Input Param ]]></text>
</staticText>
<staticText>
<reportElement x="23" y="99" width="170" height="31" uuid="be513fae-b3de-4249-824f-56d88e497340">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font fontName="Times New Roman" size="18" isBold="true"/>
</textElement>
<text><![CDATA[Manufacturer : ]]></text>
</staticText>
</frame>
</band>
</title>
<columnHeader>
<band height="16" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="60" y="-13" width="79" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="cec167d1-338c-4327-87c9-e8d562b6af56">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d86176ec-d84b-4b93-997a-12ec39fe2bba"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="138" y="-13" width="142" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="129979bf-50e6-469b-a3d0-b483b6c4c820">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d18cc433-4eec-4e98-ac63-47f15c20b391"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Inserted]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="279" y="-13" width="165" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="4254e855-c30f-44af-9e1a-f929f5a94c34">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c6fdfe7b-19cd-4a5d-8abf-681171d2a719"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Manufacturer]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="444" y="-13" width="153" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="546ecc90-d4de-4a67-9aa1-2d7dc2b1f14f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9c039bc5-f66e-467f-a303-907704885c37"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Model]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="597" y="-13" width="111" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="3d7452f4-781b-40b9-b017-7c510c384e7b">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="322b6c0e-2f6f-409c-8490-d2bfa3840131"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Model Id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="708" y="-13" width="222" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="a411dcd5-1d42-466c-aa61-7949935b30e7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d36b4bc1-f360-41bf-a258-224ca24b54a8"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Supported Protocols]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="930" y="-13" width="79" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="ed920403-94d5-422f-b160-dcdba73818cb">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="35c8a329-7e87-4a6b-9638-4a14ddbdb9d3"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[OS]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="0" y="-13" width="68" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="07abb5e5-c908-42c5-b176-3745a8faf239">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[S.No]]></text>
</staticText>
<line>
<reportElement x="-20" y="15" width="1049" height="1" uuid="ad3f5b06-8577-4845-849e-5fa41c9656d0"/>
</line>
</band>
</columnHeader>
<detail>
<band height="46" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="56" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="3aa7739c-b282-4652-9212-0ecafd9802ae">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d86176ec-d84b-4b93-997a-12ec39fe2bba"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="127" y="0" width="165" height="20" isRemoveLineWhenBlank="true" uuid="3c274351-85b8-4230-9f5c-93d3a16607d0">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d18cc433-4eec-4e98-ac63-47f15c20b391"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{INSERTED}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="319" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="612397ed-b5a3-4814-acca-eb02637aa6b6">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c6fdfe7b-19cd-4a5d-8abf-681171d2a719"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MANUFACTURER}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="450" y="0" width="140" height="20" isRemoveLineWhenBlank="true" uuid="48a7fd37-5c3c-4128-be55-524b1faeba9f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9c039bc5-f66e-467f-a303-907704885c37"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MODEL}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="610" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="bc93a0f7-029a-46e8-833e-f1d93a0e5ae5">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="322b6c0e-2f6f-409c-8490-d2bfa3840131"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MODEL_ID}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="754" y="0" width="130" height="20" isRemoveLineWhenBlank="true" uuid="b491681d-9911-4cae-a732-329cc896ec22">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d36b4bc1-f360-41bf-a258-224ca24b54a8"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{SUPPORTED_PROTOCOLS}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="926" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="f14acd18-e4cd-43d7-b71d-2efe2d57465a">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="35c8a329-7e87-4a6b-9638-4a14ddbdb9d3"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{OS}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20" isRemoveLineWhenBlank="true" uuid="7b247d2e-2508-4a1a-aee0-4f8fb2ff6b42">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="38" width="1009" height="1" uuid="2cd74f4c-6d2b-4ef3-ace7-2df7324cf744">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
</line>
<break>
<reportElement x="0" y="45" width="1009" height="1" uuid="c1f9029e-7aa0-403f-98da-77622d32c71c">
<printWhenExpression><![CDATA[$V{PAGE_COUNT}==1000]]></printWhenExpression>
</reportElement>
</break>
</band>
</detail>
<pageFooter>
<band height="41" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="10" width="1011" height="31" backcolor="#E6E6E6" uuid="c32c84ba-d6bc-45dc-84c4-75e0fff85d64"/>
<text><![CDATA[]]></text>
</staticText>
<textField isStretchWithOverflow="true" pattern="EEEEE dd MMMMM yyyy" isBlankWhenNull="true">
<reportElement x="18" y="15" width="200" height="20" uuid="47dfcb65-3b96-4833-a285-1e0a8d16994d">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="896" y="16" width="61" height="20" uuid="d7711d81-044c-49d5-be32-ee801032bfdb">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="957" y="16" width="40" height="20" uuid="f9512ca9-368f-4888-bdad-419fbb28f9a4">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
纳西尔
试试这个,
将文本字段的 "Remove Line When Blank" 属性 设置为 true
isRemoveLineWhenBlank="true"
在jrxml文件中,
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20" isRemoveLineWhenBlank="true" uuid="7b247d2e-2508-4a1a-aee0-4f8fb2ff6b42">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
将报告的 "Float Column Footer" 属性 设置为 true
isFloatColumnFooter="true"
在jrxml文件中,
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ..... isFloatColumnFooter="true" ...>
为报告"Filter Expression"设置合适的条件属性
例子,
<filterExpression><![CDATA[$F{ID}>0]]></filterExpression>
我能够找到解决方案,正如我在下面所做的那样,
- 将页脚放在列页脚带而不是页脚带中。
- 设置以下属性,
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" .... isFloatColumnFooter="true" ...>
我对 jasper 报告还很陌生,
我想做的是,我想每页获取 1000 条记录,因此为此我使用 Jaspersoft Studio 并通过提供 Print When Expression as $V{ 在详细信息带中使用 break 元素PAGE_COUNT} == 1000 而且我已经将页面高度拉伸到可以容纳 1000 条记录的某个点。所以到这里一切都很好,但问题是如果我得到总计 1200 条记录,那么它会在第一页显示 1000 条记录,但在第二页只显示 200 条记录,留下 800 行空 space,这是不被接受的客户。我想要的是,如果第二页只有 200 行,则应通过消除那些空 spaces.
来动态调整页脚添加相应的 .jrxml 代码。因此,非常感谢任何人的帮助,在此先感谢。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.9.0.final using JasperReports Library version 6.9.0-cb8f9004be492ccc537180b49c026951f4220bf3 -->
<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="BluePrint" pageWidth="1050" pageHeight="58270" columnWidth="1010" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true" uuid="554b0f60-56e2-48fb-ab4b-782b23ffc73e">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter(ATT Dev DS)"/>
<parameter name="Manufacturer" class="java.lang.String"/>
<queryString language="SQL">
<![CDATA[select id, inserted, manufacturer, model, model_id, supported_protocols, os
from DEVICE_MODEL_CONFIG dm
WHERE DM.MANUFACTURER = $P{Manufacturer}]]>
</queryString>
<field name="ID" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="ID"/>
</field>
<field name="INSERTED" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="INSERTED"/>
</field>
<field name="MANUFACTURER" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="MANUFACTURER"/>
</field>
<field name="MODEL" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="MODEL"/>
</field>
<field name="MODEL_ID" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="MODEL_ID"/>
</field>
<field name="SUPPORTED_PROTOCOLS" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SUPPORTED_PROTOCOLS"/>
</field>
<field name="OS" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="OS"/>
</field>
<title>
<band height="151" splitType="Stretch">
<frame>
<reportElement mode="Opaque" x="-20" y="-20" width="1050" height="149" backcolor="#006699" uuid="f7182fe6-ad8d-458d-87db-0a9956733132"/>
<staticText>
<reportElement x="19" y="10" width="580" height="49" uuid="55c262d1-3e27-41ae-b5aa-621651bb240d"/>
<textElement textAlignment="Left" verticalAlignment="Top">
<font fontName="Times New Roman" size="35" isBold="true"/>
</textElement>
<text><![CDATA[DeviceModelByManufacturer]]></text>
</staticText>
<textField>
<reportElement x="154" y="100" width="200" height="30" uuid="c6f91dac-00d6-4417-a74d-3ed27f2048b6">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement textAlignment="Left">
<font size="16" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Manufacturer}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="23" y="72" width="191" height="31" uuid="bfab0c72-c839-4df0-9c3a-b782435f0d2e"/>
<textElement>
<font fontName="Times New Roman" size="18" isBold="true"/>
</textElement>
<text><![CDATA[Input Param ]]></text>
</staticText>
<staticText>
<reportElement x="23" y="99" width="170" height="31" uuid="be513fae-b3de-4249-824f-56d88e497340">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font fontName="Times New Roman" size="18" isBold="true"/>
</textElement>
<text><![CDATA[Manufacturer : ]]></text>
</staticText>
</frame>
</band>
</title>
<columnHeader>
<band height="16" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="60" y="-13" width="79" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="cec167d1-338c-4327-87c9-e8d562b6af56">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d86176ec-d84b-4b93-997a-12ec39fe2bba"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="138" y="-13" width="142" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="129979bf-50e6-469b-a3d0-b483b6c4c820">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d18cc433-4eec-4e98-ac63-47f15c20b391"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Inserted]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="279" y="-13" width="165" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="4254e855-c30f-44af-9e1a-f929f5a94c34">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c6fdfe7b-19cd-4a5d-8abf-681171d2a719"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Manufacturer]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="444" y="-13" width="153" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="546ecc90-d4de-4a67-9aa1-2d7dc2b1f14f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9c039bc5-f66e-467f-a303-907704885c37"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Model]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="597" y="-13" width="111" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="3d7452f4-781b-40b9-b017-7c510c384e7b">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="322b6c0e-2f6f-409c-8490-d2bfa3840131"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Model Id]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="708" y="-13" width="222" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="a411dcd5-1d42-466c-aa61-7949935b30e7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d36b4bc1-f360-41bf-a258-224ca24b54a8"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[Supported Protocols]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="930" y="-13" width="79" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="ed920403-94d5-422f-b160-dcdba73818cb">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="35c8a329-7e87-4a6b-9638-4a14ddbdb9d3"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[OS]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="0" y="-13" width="68" height="20" isRemoveLineWhenBlank="true" forecolor="#006699" backcolor="#E6E6E6" uuid="07abb5e5-c908-42c5-b176-3745a8faf239">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box leftPadding="2" rightPadding="2">
<pen lineWidth="0.5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<text><![CDATA[S.No]]></text>
</staticText>
<line>
<reportElement x="-20" y="15" width="1049" height="1" uuid="ad3f5b06-8577-4845-849e-5fa41c9656d0"/>
</line>
</band>
</columnHeader>
<detail>
<band height="46" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="56" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="3aa7739c-b282-4652-9212-0ecafd9802ae">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d86176ec-d84b-4b93-997a-12ec39fe2bba"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="127" y="0" width="165" height="20" isRemoveLineWhenBlank="true" uuid="3c274351-85b8-4230-9f5c-93d3a16607d0">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d18cc433-4eec-4e98-ac63-47f15c20b391"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{INSERTED}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="319" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="612397ed-b5a3-4814-acca-eb02637aa6b6">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="c6fdfe7b-19cd-4a5d-8abf-681171d2a719"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MANUFACTURER}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="450" y="0" width="140" height="20" isRemoveLineWhenBlank="true" uuid="48a7fd37-5c3c-4128-be55-524b1faeba9f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="9c039bc5-f66e-467f-a303-907704885c37"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MODEL}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="610" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="bc93a0f7-029a-46e8-833e-f1d93a0e5ae5">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="322b6c0e-2f6f-409c-8490-d2bfa3840131"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{MODEL_ID}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="754" y="0" width="130" height="20" isRemoveLineWhenBlank="true" uuid="b491681d-9911-4cae-a732-329cc896ec22">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d36b4bc1-f360-41bf-a258-224ca24b54a8"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{SUPPORTED_PROTOCOLS}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="926" y="0" width="85" height="20" isRemoveLineWhenBlank="true" uuid="f14acd18-e4cd-43d7-b71d-2efe2d57465a">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="35c8a329-7e87-4a6b-9638-4a14ddbdb9d3"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$F{OS}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20" isRemoveLineWhenBlank="true" uuid="7b247d2e-2508-4a1a-aee0-4f8fb2ff6b42">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="38" width="1009" height="1" uuid="2cd74f4c-6d2b-4ef3-ace7-2df7324cf744">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
</line>
<break>
<reportElement x="0" y="45" width="1009" height="1" uuid="c1f9029e-7aa0-403f-98da-77622d32c71c">
<printWhenExpression><![CDATA[$V{PAGE_COUNT}==1000]]></printWhenExpression>
</reportElement>
</break>
</band>
</detail>
<pageFooter>
<band height="41" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="10" width="1011" height="31" backcolor="#E6E6E6" uuid="c32c84ba-d6bc-45dc-84c4-75e0fff85d64"/>
<text><![CDATA[]]></text>
</staticText>
<textField isStretchWithOverflow="true" pattern="EEEEE dd MMMMM yyyy" isBlankWhenNull="true">
<reportElement x="18" y="15" width="200" height="20" uuid="47dfcb65-3b96-4833-a285-1e0a8d16994d">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="896" y="16" width="61" height="20" uuid="d7711d81-044c-49d5-be32-ee801032bfdb">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Times New Roman" size="12" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="957" y="16" width="40" height="20" uuid="f9512ca9-368f-4888-bdad-419fbb28f9a4">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
纳西尔
试试这个,
将文本字段的 "Remove Line When Blank" 属性 设置为 true
isRemoveLineWhenBlank="true"
在jrxml文件中,
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20" isRemoveLineWhenBlank="true" uuid="7b247d2e-2508-4a1a-aee0-4f8fb2ff6b42">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
将报告的 "Float Column Footer" 属性 设置为 true
isFloatColumnFooter="true"
在jrxml文件中,
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ..... isFloatColumnFooter="true" ...>
为报告"Filter Expression"设置合适的条件属性
例子,
<filterExpression><![CDATA[$F{ID}>0]]></filterExpression>
我能够找到解决方案,正如我在下面所做的那样,
- 将页脚放在列页脚带而不是页脚带中。
- 设置以下属性,
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" .... isFloatColumnFooter="true" ...>