How to set background color from parameter in jasper report designer

此生再无相见时 提交于 2020-02-14 00:53:08

问题


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="Opaque" x="434" y="0" width="121" height="12" backcolor="#A6A6A6" uuid="e088bd9f-a0ac-4f34-9375-df765c829ec2"/>.

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

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


回答1:


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

In your case you would need

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


来源:https://stackoverflow.com/questions/40585360/how-to-set-background-color-from-parameter-in-jasper-report-designer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!