根据JasperReports中的条件更改文本字段数据颜色(前景色) [英] Change text field data color (Foreground color) based on condition in JasperReports

查看:1421
本文介绍了根据JasperReports中的条件更改文本字段数据颜色(前景色)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JasperReports的新手。我正在使用iReport设计报告。我有三个值x,y,z。如果z <然后,z的数据颜色应更改为黑色&如果z> x,则z的数据颜色应更改为红色。
请告诉我怎么做。

I'm new to JasperReports. I'm designing a report using iReport. I have three values x,y,z. If z < y then the data color for z should be changed to 'black' & if z > x then data color of z should be changed to 'red'. Please tell me how to do it.

我正在使用JDeveloper开发桌面应用程序。和iReport设计JasperReport。

I am using JDeveloper to develop desktop app. and iReport to design JasperReport.

推荐答案

你可以使用 条件样式 解决此问题。

You can use Conditional styles for solving this issue.

样本:

<style name="ZFieldStyle">
    <conditionalStyle>
        <conditionExpression><![CDATA[$F{Z} < $F{Y}]]></conditionExpression>
        <style forecolor="#000000"/>
    </conditionalStyle>
    <conditionalStyle>
        <conditionExpression><![CDATA[$F{Z}>$F{X}]]></conditionExpression>
        <style forecolor="#FF0000"/>
    </conditionalStyle>
</style>
...
<field name="X" class="java.lang.Integer"/>
<field name="Y" class="java.lang.Integer"/>
<field name="Z" class="java.lang.Integer"/>
...
<textField>
    <reportElement style="ZFieldStyle" x="200" y="0" width="100" height="20"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{Z}]]></textFieldExpression>
</textField>

这篇关于根据JasperReports中的条件更改文本字段数据颜色(前景色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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