【问题标题】:static text : field value next to it [duplicate]静态文本:它旁边的字段值[重复]
【发布时间】:2018-12-10 22:09:28
【问题描述】:

我有这个碧玉报告,我有一个静态文本“年龄:”在它旁边,我想显示年龄值。我该怎么做?

谢谢

<staticText>
            <reportElement x="-1" y="36" width="485" height="14" uuid="407bce21-d146-488f-bade-d7e7da9aaa1f"/>
            <box>
                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
            </box>
            <textElement textAlignment="Left" verticalAlignment="Middle">
                <font fontName="SansSerif" isBold="false"/>
            </textElement>
            <text><![CDATA[Age:]]></text>
        </staticText>

【问题讨论】:

    标签: jasper-reports


    【解决方案1】:

    您必须打印年龄的值,即参数、字段或变量。我假设它是一个字段,因此您通过查询接收年龄。

    所以,你想要这样的东西:

    <?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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9f81b54d-9940-4881-9423-adc74f27cece">
        <queryString>
            <![CDATA[select 9 as age from dual]]>
        </queryString>
        <field name="AGE" class="java.math.BigDecimal"/>
        <detail>
            <band height="14" splitType="Stretch">
                <staticText>
                    <reportElement uuid="407bce21-d146-488f-bade-d7e7da9aaa1f" x="0" y="0" width="25" height="14"/>
                    <box>
                        <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                        <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    </box>
                    <textElement textAlignment="Left" verticalAlignment="Middle">
                        <font fontName="SansSerif" isBold="false"/>
                    </textElement>
                    <text><![CDATA[Age:]]></text>
                </staticText>
                <textField>
                    <reportElement uuid="904205c6-35ae-4338-bae6-795f0d583f89" x="25" y="0" width="68" height="14"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{AGE}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>
    

    【讨论】:

    • 也可以将两者(静态文本和值)放在一个实体中。然后,您必须使用静态文本字段的文本字段。文本字段表达式将是这样的:"Age: " + $F{AGE}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    相关资源
    最近更新 更多