如果在jasper报告中动态看不到组件,如何避免空间? [英] How to avoid space in between when components are dynamically not visible in jasper reports?

查看:141
本文介绍了如果在jasper报告中动态看不到组件,如何避免空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有11个staticText组件。当我只显示第一个和第八个组件时,我发现它们之间存在巨大差距。我在每个组件之间没有任何空间。
我的假设是'isRemoveLineWhenBlank =true'在组件上将允许下一个组件显示在它的位置,如果它没有显示。但这不会发生在这里。

I've some 11 staticText components here. when I display only first and eight components I see a huge gap between them. I don't have any space between each component. My assumption is 'isRemoveLineWhenBlank="true"' on a component will allow the next component to display in its place if it's not getting displayed. But that's not happening here.

以下是使用的jasper报告版本:

Below is the jasper reports version used:

<dependency>
     <groupId>net.sf.jasperreports</groupId>
     <artifactId>jasperreports-fonts</artifactId>
     <version>6.0.0</version>
</dependency>

以下是代码:

<?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="sample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="acaa0a15-dc0f-462c-8d16-14f0b7325696">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <summary>
        <band height="581" splitType="Prevent">
            <staticText>
                <reportElement positionType="Float" x="0" y="19" width="381" height="41" isRemoveLineWhenBlank="true" uuid="9547d877-993c-4bb4-becc-cf70a0cc1bc2">
                    <printWhenExpression><![CDATA[true]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[Text11111111111111111111]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="60" width="381" height="41" isRemoveLineWhenBlank="true" uuid="9e7dbe2e-2fed-41c8-82ce-c0c6886c8eda">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[Text22222222222222222]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="100" width="381" height="41" isRemoveLineWhenBlank="true" uuid="75d03d01-ae6f-40e3-92d4-bed93a7cf671">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[Text3333333333333]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="260" width="381" height="41" isRemoveLineWhenBlank="true" uuid="d351c771-3c5f-4318-9a47-9363831908b6">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[7777777777777777777]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="140" width="381" height="41" isRemoveLineWhenBlank="true" uuid="cfa2937f-8ddd-4608-95e5-f3ec1d0dbea2">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[4444444444444444444]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="180" width="381" height="41" isRemoveLineWhenBlank="true" uuid="9e69343a-e1e7-4af9-90ae-d5d7c128a30a">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[55555555555555555555555]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="220" width="381" height="41" isRemoveLineWhenBlank="true" uuid="63d16d03-d637-406c-b128-06e8741a927f">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[66666666666666666]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="300" width="381" height="41" isRemoveLineWhenBlank="true" uuid="2f7e0222-a2be-47ff-be3c-3d404c40ab1c">
                    <printWhenExpression><![CDATA[true]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[888888888888888888]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="340" width="381" height="41" isRemoveLineWhenBlank="true" uuid="d87a01b5-f041-4c41-83e9-57b2e350f5b2">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[999999999999999999999999]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="380" width="381" height="41" isRemoveLineWhenBlank="true" uuid="b2017166-a731-4ebf-86f9-42a9dfe9d95a">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[1010101010101010]]></text>
            </staticText>
            <staticText>
                <reportElement positionType="Float" x="0" y="420" width="381" height="41" isRemoveLineWhenBlank="true" uuid="65c6b70e-7e12-4d38-b9d3-b9456e77c1e7">
                    <printWhenExpression><![CDATA[false]]></printWhenExpression>
                </reportElement>
                <text><![CDATA[11 11 11 11 11 11 11 11 11 11 11 ]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>

以下是显示差距的屏幕截图:

Here is the screenshot of the gap showing:

splitTypePrevent,Immediate和Stretch的输出相同。请帮忙。

The output is same for splitType "Prevent", "Immediate" and "Stretch". Please help.

推荐答案

这与 splitType 无关,要使用的2个参数是

This has nothing to do with splitType, the 2 parameters to use is


  1. isRemoveLineWhenBlank =true,删除组件

positionType =Float,将组件相对于其他组件浮动。

positionType="Float", float the component relative to others.

然后你需要有正确的设计,组件之间有0个空格。

and then you need to have correct design, 0 space between components.

您的问题是组件之间的间距为1(y differenze为40但高度为41),在所有 staticText 元素这是输出。

Your problem is the -1 space between components (the y differenze is 40 but the height is 41), switch the height to 40 in all your staticText elements this is the output.

您在其余组件之间看到的空间是高度40,如果您想要删除它,您还需要执行与 cgrim 答案

The space you see between the remaining components are the height 40, if you like to remove this also you need to do something similar as in cgrim's answer.

这篇关于如果在jasper报告中动态看不到组件,如何避免空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆