Как убрать пустые строки в случае, когда WhenPrintExpression имеет значение false? - PullRequest
0 голосов
/ 01 апреля 2020

Мы используем JasperReports 6.6.

Я использую условное выражение для отображения определенных параметров. Поведение такое, как и ожидалось. Однако, когда он не печатается, все еще остается пустое пространство.

Поля не соприкасаются, я позаботился. Здесь есть все линии удаления при бланке. Печатается, когда выражение не является функциональным, поскольку содержимое выражения не отображается, когда условие не в порядке. Другие элементы имеют тип float.

TRY

Я пробовал решения из других ответов, но они не соответствуют моей ситуации. Я уже попробовал их. Я объясню более подробно:

1) Удаление пустых записей из отчета Jasper

Для этого я не могу использовать фрейм. Я уже пытался, но, к сожалению, мне не удалось разрешить фрейм на нескольких страницах. Затем, когда размер моего кадра превышает определенный пороговый размер, он переходит непосредственно на другую страницу. Это не то, чего я ожидаю.

Об этой проблеме я задал вопрос, но так и не получил ответа: как разделить рамку на несколько страниц с помощью jasper?

2) iReport : перемещать элементы после удаления строки

Здесь, как я уже говорил в начале своей проблемы, я соблюдаю требования: - значение текстового поля пусто - проверено текстовое поле «Удалить строку, когда пусто» - позиция текстового поля type установлен в «Float» - текстовые поля не соприкасаются друг с другом

Единственное отличие состоит в том, что мои значения не обязательно пусты, например, метки, которые не связаны ни с одним значением. Но есть условие PrintWhenExpression для них.

3) iReport: Как скрыть строку с текстовыми полями, если строка данных не содержит данные другого типа

Как удалить фрейм с пустыми текстовыми полями?

JR XML SAMPLE без параметров:

Моя проблема локализована в части содержимого "Факторизация диспозиций". В источнике видно, что для этого содержимого для PrintWhenExpression установлено значение false, оно не отображается и остается пустая строка.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<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="revueDeCompte" pageWidth="595" pageHeight="842" columnWidth="511" leftMargin="42" rightMargin="42" topMargin="20" bottomMargin="20" uuid="e40ca3dd-a126-4201-ba2e-02fad2685c5a">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <parameter name="logo" class="Object" isForPrompting="false">
        <parameterDescription><![CDATA[Logo de la société]]></parameterDescription>
    </parameter>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band height="50"/>
    </pageHeader>
    <detail>
        <band height="96" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="1" width="148" height="30" uuid="76987bd1-0e7e-44f6-a4ee-aa0783847905"/>
                <textElement textAlignment="Left" verticalAlignment="Middle">
                    <font size="14" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[REVUE DE COMPTE :]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="31" width="110" height="18" uuid="13afa98d-e049-41d9-a6de-4fcb461d589b"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Type : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="52" width="110" height="18" uuid="9a6e28b4-e6e5-4f68-8e3d-e163a5610d5e"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Responsable TVy :]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="73" width="110" height="18" uuid="05c1e5bc-093f-4a63-82fd-44faef979f62"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Groupe :]]></text>
            </staticText>
        </band>
        <band height="681">
            <staticText>
                <reportElement positionType="Float" x="10" y="43" width="140" height="18" uuid="d7d5535f-f538-4535-aaee-566ec690f97d"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Fichier descriptif :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="63" width="140" height="18" uuid="b0d26808-d829-49bb-ab7d-a46992abb6ff"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Contrat cadre :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="23" width="140" height="18" uuid="7fca0ca7-09e7-491e-9d7d-85bddb9bbefc"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Onglet généralité :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="2" width="200" height="18" uuid="a2a2787d-6685-442f-a630-08a0e9ee9a43"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Fiche société client dans MTV : ]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="83" width="140" height="18" uuid="dbe422df-12d8-42a9-aa3b-9d83df0f50f4"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Entités client :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="123" width="140" height="18" uuid="d9bb820b-402e-46e5-b624-6626be5bc81c"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Dispositions facturation :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="143" width="130" height="18" isRemoveLineWhenBlank="true" uuid="28be9fae-fd4e-4156-9938-71c2f5884f85">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[TVA :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="163" width="130" height="18" isRemoveLineWhenBlank="true" uuid="14923714-00fe-4263-bffd-d81cf11f0ecf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Numéro comptable :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="183" width="130" height="18" isRemoveLineWhenBlank="true" uuid="8343a99d-8da3-436e-8ee7-d9b9b47eb5b7">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Délai règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="203" width="130" height="18" isRemoveLineWhenBlank="true" uuid="01e27294-8e0e-4645-bfd6-38b7870fb7fb">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Conditions règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="223" width="130" height="18" isRemoveLineWhenBlank="true" uuid="1a59cabe-8998-4ca7-af0f-e67dd8ef7a67">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Type envoi facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="243" width="130" height="18" isRemoveLineWhenBlank="true" uuid="dc66bc38-2120-4b64-97cc-945e623bf2c2">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Adresse facturation :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="263" width="130" height="18" isRemoveLineWhenBlank="true" uuid="9ba512ca-ef68-44c5-8e19-58e57e2d980d">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails destinataires factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="283" width="130" height="18" isRemoveLineWhenBlank="true" uuid="c93554c7-e10e-4eaf-917b-c024ec204ddf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails copies factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="303" width="130" height="18" isRemoveLineWhenBlank="true" uuid="d0d6d749-a384-48b0-8649-25b544a8d6bf">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Adresse envoi courrier :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="324" width="130" height="18" isRemoveLineWhenBlank="true" uuid="0b30dc0a-d562-4114-8f32-1b0a2dd26692">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Pièces factures :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="344" width="130" height="18" isRemoveLineWhenBlank="true" uuid="7ef51faa-5beb-4f00-ae3c-c80a9aeb6e84">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Titre facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="364" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cc4afcff-67c1-4426-8455-fe909f421492">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Commentaire tva facture :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="384" width="130" height="18" isRemoveLineWhenBlank="true" uuid="5cfb7ae1-3ef3-425e-b9ed-3e62187aefbb">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Référence contrat cadre :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="404" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cf7afd97-e009-4bf7-8a87-17c34198e8f8">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Référence fournisseur TV :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="423" width="130" height="18" isRemoveLineWhenBlank="true" uuid="cbce1351-94c1-4fca-8382-bae70a80c551">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails relance commande :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" isPrintRepeatedValues="false" x="30" y="463" width="130" height="18" isRemoveLineWhenBlank="true" uuid="6456e941-a4a5-40ae-8929-b4b2b3c6e0ab">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font size="10" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Mails relance règlement :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="504" width="200" height="18" uuid="50b8b039-07eb-4444-9149-d8e3b892196a"/>
                <textElement>
                    <font size="12" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Fiche Contacts clients dans MTV : ]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="525" width="140" height="18" isRemoveLineWhenBlank="true" uuid="b5c26cae-d87c-4e37-b309-e757495e56a7"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Contacts dirigeants :]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="10" y="565" width="140" height="18" isRemoveLineWhenBlank="true" uuid="74b40a0b-fb21-4dc0-9945-352192be69f9"/>
                <textElement>
                    <font size="12" isBold="false" isUnderline="false"/>
                </textElement>
                <text><![CDATA[Managers d'entité :]]></text>
            </staticText>
        </band>
    </detail>
    <pageFooter>
        <band height="71">
            <textField>
                <reportElement x="160" y="20" width="100" height="30" uuid="610924a5-4d05-4edc-bebf-a8abf14f274e"/>
                <textElement textAlignment="Right"/>
                <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
            <textField evaluationTime="Report">
                <reportElement x="260" y="20" width="100" height="30" uuid="5acae58f-ec6d-4074-b37a-4a1f0853f30b"/>
                <textElement textAlignment="Left"/>
                <textFieldExpression><![CDATA[" sur " + $V{PAGE_NUMBER}]]></textFieldExpression>
            </textField>
        </band>
    </pageFooter>
</jasperReport>

В этой попытке вот что я хочу:

PDF I WANT

И вот что я получаю:

PDF I GET

Не могли бы вы помочь мне убрать эти пустые строки, пожалуйста?

1 Ответ

2 голосов
/ 01 апреля 2020

Что не так

У вас небольшой вертикальный разрыв между соседними элементами.

Gap between elements

Да, оно маленькое (всего 3px ), но есть.

Как исправить

Я изменил y положение всех элементов. Я удалил этот пробел:

y-позиция элемента = (y-позиция + высота) предыдущего элемента

Делая этот трюк, я сохранил 98 px для "Managers d'entité:" label. Да, не слишком много, но в результате больше нет новой страницы.

Difference

Модифицированный дизайн выглядит так:

New design

Результат для этого немного модифицированного шаблона:

Preview at JSS

На данный момент, в элемент (ы) удаления корпуса - все элементы ниже будут извлечены без каких-либо проблем.

Так работает механизм JasperReports. Вы должны играть по этим правилам.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...