Use the value of a parameter in a style tag


I am looking for the ability to use the value of a parameter passed into the report to be used as the hex colour value of the background in a conditional style, does anyone know how to achieve this?

My code so far:

<style name="Parameterised Text Colour">
            <style backcolor={$P{style}}/>
            <style backcolor="#000000"/>

Any help is greatly appreciated

jack.bracey_1's picture
Joined: Sep 3 2018 - 3:06am
Last seen: 1 month 1 week ago

1 Answer:


As far as I know the color attributes are just static ones.... so you can't set these to a dynamic value concerning at a parameter or even a field expression.

I created a java "PreProcessor" when loading the jrxml (per JasperAPI) and changed the style colors per JRDesignAPI (so e.g. each month could have another color defined by the user. so I created 12 styles per API and set the style background-color to the database value, afterwards I recompile the (changed) design and pass this to the normal fill manager. Works fine for my purose. :-) Perhaps just an idea for your solution (if you also call your reports from a java application)

hth + regards


C-Box's picture
Joined: Jul 19 2006 - 5:58pm
Last seen: 16 hours 20 min ago