首页 文章

静态文本:旁边的字段值[重复]

提问于
浏览
-2

这个问题在这里已有答案:

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

谢谢

<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>

1 回答

  • 1

    您必须打印age的值,即参数,字段或变量 . 我假设它是一个字段,所以你通过查询接收年龄 .

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

    <?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>
    

相关问题