如何动态更改字体颜色?

时间:2022-08-14 20:29:35

Here is my xml content:

这是我的xml内容:

span style="background-color: rgb(255, 255, 0); 

This Background color comes along with my Java coding. As this background color is dynamic so whatever color may come in my report.

这种背景颜色伴随着我的Java编码。因为这种背景颜色是动态的,所以我的报告中可能会出现任何颜色。

So my question is how to input the given color to JasperReports's report using iReport with that dynamic color each time.

所以我的问题是如何使用具有该动态颜色的iReport每次向JasperReports的报告输入给定的颜色。

Eg: First time the color may be yellow, Next time the color may be orange and so on..

例如:第一次颜色可能是黄色,下次颜色可能是橙色等等。

1 个解决方案

#1


1  

You would need to pass you color code as parameter to jasper report and later use it in jasper report. Somewhat like following.
Declare following parameters:

您需要将颜色代码作为参数传递给jasper报告,然后在jasper报告中使用它。有点像跟随。声明以下参数:

<parameter name="r" class="java.lang.Integer"/>
<parameter name="g" class="java.lang.Integer"/>
<parameter name="b" class="java.lang.Integer"/>

Use it as follows:

使用方法如下:

span style="background-color: rgb("+$P{r}+", "+$P{g}+", "+$P{b}+")" 

Hope it helps.

希望能帮助到你。

#1


1  

You would need to pass you color code as parameter to jasper report and later use it in jasper report. Somewhat like following.
Declare following parameters:

您需要将颜色代码作为参数传递给jasper报告,然后在jasper报告中使用它。有点像跟随。声明以下参数:

<parameter name="r" class="java.lang.Integer"/>
<parameter name="g" class="java.lang.Integer"/>
<parameter name="b" class="java.lang.Integer"/>

Use it as follows:

使用方法如下:

span style="background-color: rgb("+$P{r}+", "+$P{g}+", "+$P{b}+")" 

Hope it helps.

希望能帮助到你。