Sumon Bappi
Sumon Bappi

Reputation: 2019

How to set background color from parameter in Jasper Report designer

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.

What can I try next? I have researched it, but no luck.

Upvotes: 7

Views: 13646

Answers (2)

조영문
조영문

Reputation: 11

enter image description here

click the "transparent"

Upvotes: 1

dada67
dada67

Reputation: 5093

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>
  ...

Upvotes: 13

Related Questions