当前位置: 首页 > 知识库问答 >
问题:

如何在页面第二列的第一行打印文本字段?

伍成仁
2023-03-14

JRXML

 <?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports     Library version 6.4.1  -->
<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_Landscape" columnCount="2" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="400" columnSpacing="2" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b0cd6df7-ceab-4f93-aff6-668d7c75ce9b">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="resourcePath" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA[""]]></defaultValueExpression>
</parameter>
<parameter name="Einrichtungspseudonym" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["Einrichtungspseudonym"]]></defaultValueExpression>
</parameter>
<parameter name="reportPart" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["reportPart"]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
    <![CDATA[]]>
</queryString>
<field name="level" class="java.lang.Integer"/>
<field name="label" class="java.lang.String"/>
<field name="pageIndex" class="java.lang.Integer"/>
<background>
    <band splitType="Stretch"/>
</background>
<pageHeader>
    <band height="50" splitType="Stretch">
        <frame>
            <reportElement x="0" y="0" width="702" height="50" backcolor="rgba(227, 218, 218, 0.46666667)" uuid="6ca5e261-9531-43ef-80ed-828dc6b4524f"/>
            <rectangle>
                <reportElement x="0" y="18" width="702" height="17" forecolor="#A1A1A1" backcolor="#D9D9D9" uuid="54beea72-4243-48ea-856e-29d9da8a0431">
                    <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="0.5" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
            <textField isStretchWithOverflow="true">
                <reportElement style="Kopfzeile" x="2" y="0" width="330" height="50" uuid="f9f8c8d7-253c-46bd-b8ab-fe737db7070d"/>
                <textFieldExpression><![CDATA["Tabellen- und Abbildungsverzeichnis"]]></textFieldExpression>
                <anchorNameExpression><![CDATA["Tabellen- und Abbildungsverzeichnis"]]></anchorNameExpression>
            </textField>
            <image>
                <reportElement x="632" y="0" width="70" height="50" uuid="16558eec-b7b6-4fc4-b6ea-6fb3ff4b5e2f"/>
                <imageExpression><![CDATA[$P{resourcePath}+"Logo_vertical_RGB.png"]]></imageExpression>
            </image>
        </frame>
    </band>
</pageHeader>
<columnHeader>
    <band height="20" splitType="Stretch">
        <textField isStretchWithOverflow="true">
            <reportElement style="Kapitelüberschrift" isPrintRepeatedValues="false" x="0" y="0" width="394" height="20" uuid="2d7b27c2-91b1-4d62-97b6-ca0d4dd1c099"/>
            <textFieldExpression><![CDATA["Tabellen- und Abbildungsverzechnis"]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true">
            <reportElement style="Kapitelüberschrift" isPrintRepeatedValues="false" x="412" y="0" width="388" height="20" uuid="edc812df-deaa-4511-9b46-1c5c963b31a9"/>
            <textFieldExpression><![CDATA["Abbildungen der Ergebniszusammenfassung"]]></textFieldExpression>
        </textField>
    </band>
</columnHeader>
<detail>
    <band height="113" splitType="Stretch">
        <frame>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="411" y="3" width="340" height="17" isRemoveLineWhenBlank="true" uuid="517ee347-d843-43d4-9855-b4c1cc6b490c">
                <printWhenExpression><![CDATA[$F{level}  == 21]]></printWhenExpression>
            </reportElement>
            <rectangle>
                <reportElement stretchType="ContainerHeight" x="0" y="0" width="11" height="17" isRemoveLineWhenBlank="true" forecolor="#E8A435" backcolor="#FCCF3A" uuid="3a9abeb8-b2a9-4650-b034-9eb7815e7f09">
                    <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="0.0" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
            <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                <reportElement style="Standard" x="20" y="0" width="290" height="17" isRemoveLineWhenBlank="true" uuid="f96bf175-4d0f-494f-8eb6-ac9270a53ec5"/>
                <textElement textAlignment="Left"/>
                <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement key="" style="Standard" x="310" y="0" width="30" height="17" isRemoveLineWhenBlank="true" uuid="eadc2beb-1873-44a7-b8ca-26815fc64601"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 4]]></textFieldExpression>
            </textField>
        </frame>
        <frame>
            <reportElement isPrintRepeatedValues="false" x="0" y="3" width="351" height="110" isRemoveLineWhenBlank="true" uuid="f7f28f9f-f011-42c5-b10b-68986a90ce92">
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            </reportElement>
            <frame>
                <reportElement positionType="Float" x="0" y="0" width="351" height="18" isRemoveLineWhenBlank="true" uuid="870d4b8e-dcf2-40dc-8c1a-4e77b878b898">
                    <printWhenExpression><![CDATA[$F{level} == 31]]></printWhenExpression>
                </reportElement>
                <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                    <reportElement style="Standard_mit_html" mode="Transparent" x="20" y="0" width="301" height="18" isRemoveLineWhenBlank="true" uuid="6fee51d3-a833-48e2-8eba-72228aeb58d7">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement textAlignment="Left" markup="styled"/>
                    <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Standard" x="321" y="0" width="30" height="18" isRemoveLineWhenBlank="true" uuid="5868d8c8-7eb1-495b-b848-a193237679a2">
                        <property name="com.jaspersoft.studio.unit.y" value="cm"/>
                    </reportElement>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[6]]></textFieldExpression>
                </textField>
                <rectangle>
                    <reportElement stretchType="ContainerHeight" x="0" y="0" width="11" height="18" isRemoveLineWhenBlank="true" forecolor="#5A49F2" backcolor="#783AFC" uuid="f52cbdd2-131c-4726-9945-dea36bb1275c">
                        <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                    </reportElement>
                    <graphicElement>
                        <pen lineWidth="0.0" lineStyle="Solid"/>
                    </graphicElement>
                </rectangle>
            </frame>
            <frame>
                <reportElement positionType="Float" x="0" y="18" width="351" height="18" isRemoveLineWhenBlank="true" uuid="429e6789-ec18-4e23-b84a-ddff038ddf31">
                    <printWhenExpression><![CDATA[$F{level} == 32]]></printWhenExpression>
                </reportElement>
                <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                    <reportElement style="Standard_mit_html" mode="Transparent" x="20" y="8" width="301" height="10" isRemoveLineWhenBlank="true" uuid="3e6b8d9c-94e8-47eb-b1ca-926607daf19e">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement textAlignment="Left" markup="styled"/>
                    <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Standard" x="321" y="8" width="30" height="10" isRemoveLineWhenBlank="true" uuid="45cb3231-65b2-4b03-8387-cb67d968d4de">
                        <property name="com.jaspersoft.studio.unit.y" value="cm"/>
                    </reportElement>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[6]]></textFieldExpression>
                </textField>
                <rectangle>
                    <reportElement stretchType="ContainerHeight" x="0" y="8" width="11" height="10" isRemoveLineWhenBlank="true" forecolor="#1BAEF7" backcolor="#56B4FC" uuid="8f7cd5e1-539e-455d-992d-7754d5b50aef">
                        <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                    </reportElement>
                    <graphicElement>
                        <pen lineWidth="0.0" lineStyle="Solid"/>
                    </graphicElement>
                </rectangle>
            </frame>
        </frame>
    </band>
</detail>
<pageFooter>
    <band height="31" splitType="Stretch">
        <frame>
            <reportElement x="0" y="0" width="802" height="31" uuid="99847b36-f679-406b-b7c6-44151acc24e4">
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
            </reportElement>
            <textField isStretchWithOverflow="true">
                <reportElement style="Fußzeile 8,5pt" x="0" y="0" width="394" height="31" uuid="5d388cd5-181d-48b6-981a-9034f2ca3edf"/>
                <textElement verticalAlignment="Bottom"/>
                <textFieldExpression><![CDATA["© report: Quartalsbericht "+$P{reportPart}+" für Einrichtung "+$P{Einrichtungspseudonym}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" evaluationTime="Master">
                <reportElement style="Fußzeile 8,5pt" x="408" y="0" width="394" height="31" uuid="4efe47cc-4b4c-415a-9c38-1cfabd3c347d">
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                </reportElement>
                <textElement textAlignment="Right" verticalAlignment="Bottom"/>
                <textFieldExpression><![CDATA[$V{MASTER_CURRENT_PAGE} != null ? $V{MASTER_CURRENT_PAGE}+"/"+$V{MASTER_TOTAL_PAGES} : $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>

我也尝试了另一种方法,即创建一个单列页面,然后将字段放在两个框架中,一个在页面的左侧,另一个在写端。但其结果与以往的方法相同。单列页的代码:

 <?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="Abbildungsverzeichnis" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="702" leftMargin="70" rightMargin="70" topMargin="42" bottomMargin="42" whenResourceMissingType="Empty" uuid="6e74177b-d551-4a75-ae51-6cdde3f284ce">
<property name="com.jaspersoft.studio.unit." value="cm"/>
<property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
<template><![CDATA[$P{resourcePath}+"styles.jrtx"]]></template>
<parameter name="resourcePath" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA[""]]></defaultValueExpression>
</parameter>
<parameter name="Einrichtungspseudonym" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["Einrichtungspseudonym"]]></defaultValueExpression>
</parameter>
<parameter name="Berichtsquartal" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["Berichtsquartal"]]></defaultValueExpression>
</parameter>
<queryString language="XPath">
    <![CDATA[/QSDialyse2018QuartalsberichtLe]]>
</queryString>
<field name="level" class="java.lang.Integer"/>
<field name="label" class="java.lang.String"/>
<field name="pageIndex" class="java.lang.Integer"/>
<background>
    <band splitType="Stretch"/>
</background>
<pageHeader>
    <band height="50">
        <frame>
            <reportElement x="0" y="0" width="702" height="50" backcolor="rgba(227, 218, 218, 0.46666667)" uuid="06038290-751d-4458-807d-96a3e51e7d1d"/>
            <rectangle>
                <reportElement x="0" y="18" width="702" height="17" forecolor="#A1A1A1" backcolor="#D9D9D9" uuid="ca066fcc-d491-4f4b-aa09-17ae01773098">
                    <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="0.5" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
            <textField isStretchWithOverflow="true">
                <reportElement style="Kopfzeile" x="2" y="0" width="330" height="50" uuid="4a0983f4-b41e-4828-a73d-7e285cb31887"/>
                <textFieldExpression><![CDATA["Tabellen- und Abbildungsverzeichnis"]]></textFieldExpression>
                <anchorNameExpression><![CDATA["Tabellen- und Abbildungsverzeichnis"]]></anchorNameExpression>
            </textField>
        </frame>
    </band>
</pageHeader>
<detail>
    <band height="110" splitType="Stretch">
        <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="0" width="351" height="110" isRemoveLineWhenBlank="true" uuid="c5f75321-dadb-4152-acab-6208ed6878de">
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            </reportElement>
            <frame>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="0" width="351" height="18" isRemoveLineWhenBlank="true" uuid="a3604c51-5a78-4577-b0f8-2cc19c403996">
                    <printWhenExpression><![CDATA[$F{level} == 31]]></printWhenExpression>
                </reportElement>
                <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                    <reportElement style="Standard_mit_html" isPrintRepeatedValues="false" mode="Transparent" x="20" y="0" width="301" height="18" isRemoveLineWhenBlank="true" uuid="379fcff2-021d-4761-a89a-eeb772723b1b">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    </reportElement>
                    <box>
                        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement textAlignment="Left" markup="styled"/>
                    <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Standard" x="321" y="0" width="30" height="18" isRemoveLineWhenBlank="true" uuid="207a4316-1f91-4886-91f9-9a86c788a83f">
                        <property name="com.jaspersoft.studio.unit.y" value="cm"/>
                    </reportElement>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 4]]></textFieldExpression>
                </textField>
                <rectangle>
                    <reportElement stretchType="ContainerHeight" x="0" y="0" width="11" height="18" isRemoveLineWhenBlank="true" forecolor="#5A49F2" backcolor="#783AFC" uuid="f9a97c9f-4bc7-4ede-b082-d39a697f10ec">
                        <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                    </reportElement>
                    <graphicElement>
                        <pen lineWidth="0.0" lineStyle="Solid"/>
                    </graphicElement>
                </rectangle>
            </frame>
            <frame>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="18" width="351" height="18" isRemoveLineWhenBlank="true" uuid="c01291d6-8266-4368-bd93-8a9dc0b52770">
                    <printWhenExpression><![CDATA[$F{level} == 32]]></printWhenExpression>
                </reportElement>
                <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                    <reportElement style="Standard_mit_html" isPrintRepeatedValues="false" mode="Transparent" x="20" y="8" width="301" height="10" isRemoveLineWhenBlank="true" uuid="8213d17a-5e7d-4fd2-81b2-509045752b80">
                        <property name="local_mesure_unitheight" value="pixel"/>
                        <property name="com.jaspersoft.studio.unit.height" value="px"/>
                        <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    </reportElement>
                    <textElement textAlignment="Left" markup="styled"/>
                    <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                    <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
                </textField>
                <textField isStretchWithOverflow="true">
                    <reportElement style="Standard" x="321" y="8" width="30" height="10" isRemoveLineWhenBlank="true" uuid="1ced4974-5ea1-4ef1-86cb-dfd3fa5bd736">
                        <property name="com.jaspersoft.studio.unit.y" value="cm"/>
                    </reportElement>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 4]]></textFieldExpression>
                </textField>
                <rectangle>
                    <reportElement stretchType="ContainerHeight" x="0" y="8" width="11" height="10" isRemoveLineWhenBlank="true" forecolor="#1BAEF7" backcolor="#56B4FC" uuid="ee55c1ea-8c69-45ae-86d8-6166dcddb18b">
                        <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                    </reportElement>
                    <graphicElement>
                        <pen lineWidth="0.0" lineStyle="Solid"/>
                    </graphicElement>
                </rectangle>
            </frame>


        </frame>
        <frame>
            <reportElement isPrintRepeatedValues="false" x="362" y="0" width="340" height="17" isRemoveLineWhenBlank="true" uuid="d1247e47-59b4-4930-ad78-c76a0374f555">
                <property name="ShowOutOfBoundContent" value="false"/>
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                <printWhenExpression><![CDATA[$F{level}  == 21]]></printWhenExpression>
            </reportElement>
            <rectangle>
                <reportElement stretchType="ContainerHeight" x="5" y="0" width="11" height="17" isRemoveLineWhenBlank="true" forecolor="#E8A435" backcolor="#FCCF3A" uuid="38bc71e5-6d69-4ab3-8a6b-0c1bba53a26c">
                    <property name="com.jaspersoft.studio.unit.height" value="cm"/>
                </reportElement>
                <graphicElement>
                    <pen lineWidth="0.0" lineStyle="Solid"/>
                </graphicElement>
            </rectangle>
            <textField isStretchWithOverflow="true" hyperlinkType="LocalAnchor">
                <reportElement style="Standard" x="20" y="0" width="290" height="17" isRemoveLineWhenBlank="true" uuid="b19a02f7-3d3f-4086-86ed-5dc6859e5fd1"/>
                <textElement textAlignment="Left"/>
                <textFieldExpression><![CDATA[$F{label}]]></textFieldExpression>
                <hyperlinkAnchorExpression><![CDATA[$F{label}]]></hyperlinkAnchorExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement key="" style="Standard" x="310" y="0" width="30" height="17" isRemoveLineWhenBlank="true" uuid="bc43bd36-7466-457c-95e6-384410c05cbe"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA[$V{PAGE_NUMBER} + $F{pageIndex} + 4]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</detail>
<pageFooter>
    <band height="31">
        <frame>
            <reportElement x="0" y="0" width="702" height="31" uuid="ca4af90c-cc2f-406c-865f-59680b968139">
                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
            </reportElement>
            <textField isStretchWithOverflow="true">
                <reportElement style="Fußzeile 8,5pt" x="0" y="0" width="351" height="31" uuid="c3e365c7-5dde-419e-a0da-950bf7d16710"/>
                <textElement verticalAlignment="Bottom"/>
                <textFieldExpression><![CDATA["© report: Quartalsbericht "+$P{Berichtsquartal}+" für Einrichtung "+$P{Einrichtungspseudonym}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" evaluationTime="Master">
                <reportElement style="Fußzeile 8,5pt" x="351" y="0" width="351" height="31" uuid="94da8446-69d3-4dc9-a791-d413082e42cc">
                    <property name="com.jaspersoft.studio.unit.x" value="cm"/>
                </reportElement>
                <textElement textAlignment="Right" verticalAlignment="Bottom"/>
                <textFieldExpression><![CDATA[$V{MASTER_CURRENT_PAGE} != null ? $V{MASTER_CURRENT_PAGE}+"/"+$V{MASTER_TOTAL_PAGES} : $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </frame>
    </band>
</pageFooter>

共有1个答案

羊舌昆杰
2023-03-14

与您的第一次尝试相关,您误解了多列页面的工作方式。

您不是通过相应地定位字段来决定字段将进入哪一列,而是jasper-report将根据printorder中断到下一列,如果是垂直的,则当它到达页尾或通过组或

<break type="Column">
    <reportElement x="0" y="15" width="100" height="1" uuid="c082e856-5507-4b0f-9dde-01b7fac85a4f"/>
</break>

如果您确信第一部分将适合页面的第一列,如果不适合,则会在第二列溢出,并且分页符将导致分页符,则此解决方案是可行的,

<?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="2columnsbreak" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="81a13ec8-f22d-44f0-9335-c15e2fe28614">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="CVS"/>
    <queryString language="csv">
        <![CDATA[]]>
    </queryString>
    <field name="User" class="java.lang.String"/>
    <field name="Rep" class="java.lang.Integer"/>
    <group name="UserWithLowRep" isStartNewColumn="true">
        <groupExpression><![CDATA[($F{Rep}<100000)]]></groupExpression>
    </group>
    <columnHeader>
        <band height="24" splitType="Stretch">
            <textField evaluationTime="Group" evaluationGroup="UserWithLowRep">
                <reportElement x="0" y="0" width="270" height="20" uuid="456c89e2-8e48-4e01-95ff-e56f2b150e0f"/>
                <textFieldExpression><![CDATA[($V{COLUMN_NUMBER}==1?"User with high rep":"User with low rep")]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="23" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="270" height="20" uuid="2daf5f8f-87a1-4f7e-b1de-2807811a1ddd"/>
                <textFieldExpression><![CDATA[$F{User}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

groupexpression更改时将中断为新列

输出

请注意如何使用内置的变量$V{COLUMN_NUMBER}根据列的需要输出和格式化数据。在本例2列中,它的值为1(用于第一列中的数据)或2(用于第二列中的数据)。

 类似资料: