根据条件格式化字段数据颜色 [英] Formatting field data color based on condition

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

问题描述

我是JasperReports的新手。我正在使用iReport设计报告。我的要求是我有两个值(字段)x,y来比较。如果x <然后,y的数据颜色应更改为黑色和黑色。如果更大,则y的数据颜色应更改为红色。

I'm new to JasperReports. I'm designing report using iReport. My requirement is I have two values (Fields) x,y to compare. If x < y then the data color for y should be changed to 'black' & if greater then data color of y should be changed to 'red'.

请告诉我如何继续这个&在哪里验证。

Please advice me as to how to proceed on this & where to validate.

推荐答案

有一个讨论,这可能是最相关的部分:

There's a discussion at the JasperForge forums on the topic, this is probably the most relevant part:


首先拖放您想要有两次动态颜色的字段。将第一个字段的背景颜色更改为黄色,将第二个字段更改为红色。现在右键单击黄色字段,单击属性,选择常用选项卡,然后在'打印表达式'框中写入此代码:(确保将myconditionalfield替换为您的实际字段名称)$ F {MyConditinalField} .intValue()> = 5& ;&安培; $ F {MyConditinalField} .intValue()< 10?Boolean.TRUE:Boolean.FALSE // if> = 5且< 10然后显示黄色字段//红色字段代码在同一个地方就像$ F { MyConditinalField} .intValue()> = 10?Boolean.TRUE:Boolean.FALSE希望这会有所帮助。

First drag and drop the field that you want to have dyanamic color twice. Change background color for first field to Yellow and the second field to Red. Now right click Yellow field, click Properties, select Common tab and write this code in the 'Print when expression' box: (make sure to replace myconditionalfield with your actual field name) $F{MyConditinalField}.intValue()>= 5 && $F{MyConditinalField}.intValue()<10?Boolean.TRUE:Boolean.FALSE //if >=5 and <10 then show Yellow field //Code for Red field at the same place just like above $F{MyConditinalField}.intValue()>= 10?Boolean.TRUE:Boolean.FALSE Hope this helps.

它不是 你需要什么,但可能足够接近,推动你朝着正确的方向前进。

It's not exactly what you need, but might likely be close enough to push you in the right direction.

这篇关于根据条件格式化字段数据颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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