如何在jasper报表设计器中从参数设置背景颜色 [英] How to set background color from parameter in jasper report designer

查看:1368
本文介绍了如何在jasper报表设计器中从参数设置背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jasper报告来设计报告。我有一个报告,其中有一个静态文本。我想通过参数值设置它的背景颜色。在xml中,它为这样的文本生成 -

I am using jasper report for designing report. I have a report where there is a static text. I want to set the background color of it by parameter value. In the xml it generates for the text like this -

< reportElement mode =Opaquex =434y =0 width =121height =12backcolor =#A6A6A6uuid =e088bd9f-a0ac-4f34-9375-df765c829ec2/>

现在我需要从一个来自数据库的参数设置背景颜色。在这里像#A6A6A6

Now I need to set the backcolor from a parameter which will come from database. for here like #A6A6A6.

有人可以帮我这个吗?我用google搜索但没有运气。

Can anyone please help me on this please? I have googled for it but no luck.

推荐答案

你可以用 net.sf.jasperreports.style。* 元素级别属性(为此可以将表达式作为值)。

You can do that with net.sf.jasperreports.style.* element level properties (for which you can have expressions as values).

在您的情况下,您需要

<textField>
  <reportElement ...>
    <propertyExpression name="net.sf.jasperreports.style.backcolor">$P{someColor}</propertyExpression>
  </reportElement>
  ...

这篇关于如何在jasper报表设计器中从参数设置背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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