碧玉报告 - 水平对齐动态文本字段和它们的标签 [英] Jasper Reports - align dynamic text fields and their labels horizontally

查看:198
本文介绍了碧玉报告 - 水平对齐动态文本字段和它们的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用碧玉报告5.2,iReport的5.2和导出RTF格式和PDF格式的报告。

I'm using Jasper report 5.2, iReport 5.2 and exporting the report in RTF and PDF formats.

在我的报告中,我想随着水平对齐如

In my report I want to add few text fields along with their (static text)labels aligned horizontally like

         Name:  $F{name}
          Age:  $F{age}
Date of Birth:  $F{dateOfBirth}

不过,我无法将它们对齐。这是我试过

But I'm unable to align them. This is what I tried

  • 职位类型:浮动(适用于所有静态文本和字段)
  • 伸展式:无弹力(适用于所有静态文本和字段)
  • 舒展溢出:真(所有动态文本字段)
  • Position Type: float (for all static text and fields)
  • Stretch Type: no stretch (for all static text and fields)
  • Stretch With Overflow: True (for all dynamic text fields)

图片显示了我得到什么,我想要的。 此外,我的文本字段的内容是动态的,即内容的大小可能会有所不同。

The image shows what I get and what I want. Moreover, my text field's content is dynamic i.e. content size could vary.

我读过很多论坛也没有找到一个解决办法,请建议。

I've read many forums but could not find a solution, please suggest.

感谢

推荐答案

它可以轻松完成集装箱的帮助 - 在框架的元素

It can be easily done with help of container - the Frame element.

您应该把框架的用的位置类型的是浮动并把他们俩的 STATICTEXT 的(标签), textField的的。

You should put Frame with Position Type as Float and put to them both staticText (label) and textField.

有关的 textField的的我给自己定的位置类型的是浮动舒展Overlfow 的是

For textField I've set Position Type as Float the Stretch With Overlfow as true.

JRXML 的文件:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="textfields_allign" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d855bf18-5e9b-4060-8caa-3fdd08abce3b">
    <parameter name="name" class="java.lang.String"/>
    <parameter name="id" class="java.lang.String"/>
    <parameter name="date" class="java.lang.String"/>
    <title>
        <band height="69" splitType="Stretch">
            <frame>
                <reportElement uuid="314bfd5b-7b0a-42f4-aca3-e61f0283f126" positionType="Float" x="213" y="1" width="243" height="20"/>
                <staticText>
                    <reportElement uuid="e07201bb-a677-4dc9-a332-f94e6eca2722" positionType="Float" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <text><![CDATA[Name]]></text>
                </staticText>
                <textField isStretchWithOverflow="true">
                    <reportElement uuid="66c93a44-9015-4ae9-bf05-b68b2420f3ef" positionType="Float" x="121" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$P{name}]]></textFieldExpression>
                </textField>
            </frame>
            <frame>
                <reportElement uuid="8311a483-955e-4280-a9ac-513d7d34495b" positionType="Float" x="213" y="21" width="243" height="20"/>
                <staticText>
                    <reportElement uuid="da404b4e-7908-40ae-8e1b-38e19d9ddc7f" positionType="Float" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <text><![CDATA[ID]]></text>
                </staticText>
                <textField isStretchWithOverflow="true">
                    <reportElement uuid="e0e312e8-cd2f-48af-8ae8-df95c6195488" positionType="Float" x="121" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$P{id}]]></textFieldExpression>
                </textField>
            </frame>
            <frame>
                <reportElement uuid="8ff2baf9-b0ec-4c8a-b54a-9edd08b200cc" positionType="Float" x="213" y="41" width="243" height="20"/>
                <staticText>
                    <reportElement uuid="b8d97db0-250a-43c8-a2f3-2fa3668c5d15" positionType="Float" x="0" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <text><![CDATA[Date]]></text>
                </staticText>
                <textField isStretchWithOverflow="true">
                    <reportElement uuid="4daa4d17-28be-4ac8-8e1e-2efbeec5f690" positionType="Float" x="121" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$P{date}]]></textFieldExpression>
                </textField>
            </frame>
        </band>
    </title>
</jasperReport>

报告的设计的的iReport 的:

其结果将是(通过的的iReport 的preVIEW):

The result will be (via iReport preview):

这篇关于碧玉报告 - 水平对齐动态文本字段和它们的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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