如何在iReport中设置整个页面的背景颜色?

发布于 2024-12-20 01:00:14 字数 67 浏览 2 评论 0原文

我使用的是 iReport 3.7.4。 我想为整个页面设置背景颜色。我没有找到任何背景颜色的报表属性。 有人能帮我吗?

I am using iReport 3.7.4.
I want to set background color to entire page.I didn't found any report property for background color.
Can anyone help me in this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

影子是时光的心 2024-12-27 01:00:14

您可以在Background Band的帮助下解决问题。

我已将 staticText 元素放在 Background Band 上,并将 mode 属性设置为 < em>不透明并设置backcolor属性。

示例:

<jasperReport ... pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="338"/>
    <queryString language="xPath">
        <![CDATA[/Northwind/Customers]]>
    </queryString>
    <field name="CustomerID" class="java.lang.String">
        <fieldDescription><![CDATA[CustomerID]]></fieldDescription>
    </field>
    <field name="CompanyName" class="java.lang.String">
        <fieldDescription><![CDATA[CompanyName]]></fieldDescription>
    </field>
    <field name="ContactName" class="java.lang.String">
        <fieldDescription><![CDATA[ContactName]]></fieldDescription>
    </field>
    <field name="ContactTitle" class="java.lang.String">
        <fieldDescription><![CDATA[ContactTitle]]></fieldDescription>
    </field>
    <field name="Address" class="java.lang.String">
        <fieldDescription><![CDATA[Address]]></fieldDescription>
    </field>
    <field name="City" class="java.lang.String">
        <fieldDescription><![CDATA[City]]></fieldDescription>
    </field>
    <field name="PostalCode" class="java.lang.String">
        <fieldDescription><![CDATA[PostalCode]]></fieldDescription>
    </field>
    <field name="Country" class="java.lang.String">
        <fieldDescription><![CDATA[Country]]></fieldDescription>
    </field>
    <field name="Phone" class="java.lang.String">
        <fieldDescription><![CDATA[Phone]]></fieldDescription>
    </field>
    <field name="Fax" class="java.lang.String">
        <fieldDescription><![CDATA[Fax]]></fieldDescription>
    </field>
    <background>
        <band height="842" splitType="Stretch">
            <staticText>
                <reportElement mode="Opaque" x="0" y="0" width="595" height="842" backcolor="#CCFFCC"/>
                <textElement/>
                <text><![CDATA[]]></text>
            </staticText>
        </band>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="128" y="29" width="298" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[The report with the background color]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement x="19" y="0" width="147" height="20"/>
                <box leftPadding="10"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{CompanyName}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="166" y="0" width="260" height="20"/>
                <box leftPadding="10"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

Background Band 的高度应等于整个报表的高度,并且“透明”staticText 元素必须占据该 Band 的整个空间。

结果将是:
带有背景颜色的报告

You can solve issue with help of Background Band.

I've put staticText element on Background Band and set mode attribute as Opaque and set the backcolor property.

The sample:

<jasperReport ... pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="338"/>
    <queryString language="xPath">
        <![CDATA[/Northwind/Customers]]>
    </queryString>
    <field name="CustomerID" class="java.lang.String">
        <fieldDescription><![CDATA[CustomerID]]></fieldDescription>
    </field>
    <field name="CompanyName" class="java.lang.String">
        <fieldDescription><![CDATA[CompanyName]]></fieldDescription>
    </field>
    <field name="ContactName" class="java.lang.String">
        <fieldDescription><![CDATA[ContactName]]></fieldDescription>
    </field>
    <field name="ContactTitle" class="java.lang.String">
        <fieldDescription><![CDATA[ContactTitle]]></fieldDescription>
    </field>
    <field name="Address" class="java.lang.String">
        <fieldDescription><![CDATA[Address]]></fieldDescription>
    </field>
    <field name="City" class="java.lang.String">
        <fieldDescription><![CDATA[City]]></fieldDescription>
    </field>
    <field name="PostalCode" class="java.lang.String">
        <fieldDescription><![CDATA[PostalCode]]></fieldDescription>
    </field>
    <field name="Country" class="java.lang.String">
        <fieldDescription><![CDATA[Country]]></fieldDescription>
    </field>
    <field name="Phone" class="java.lang.String">
        <fieldDescription><![CDATA[Phone]]></fieldDescription>
    </field>
    <field name="Fax" class="java.lang.String">
        <fieldDescription><![CDATA[Fax]]></fieldDescription>
    </field>
    <background>
        <band height="842" splitType="Stretch">
            <staticText>
                <reportElement mode="Opaque" x="0" y="0" width="595" height="842" backcolor="#CCFFCC"/>
                <textElement/>
                <text><![CDATA[]]></text>
            </staticText>
        </band>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="128" y="29" width="298" height="20"/>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true"/>
                </textElement>
                <text><![CDATA[The report with the background color]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="20" splitType="Stretch">
            <textField>
                <reportElement x="19" y="0" width="147" height="20"/>
                <box leftPadding="10"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{CompanyName}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="166" y="0" width="260" height="20"/>
                <box leftPadding="10"/>
                <textElement/>
                <textFieldExpression><![CDATA[$F{City}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

The height of the Background Band should be equal to the whole report's height and the "transparent" staticText element must occupy the entire space of this band.

The result will be:
report with background color

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文