Is it possible to set the HTML class attribute?


It is possible to set the html id using 

Is there any way to set the html class attribute in a similar way?


phantastes's picture
Joined: Aug 22 2008 - 2:05pm
Last seen: 10 years 4 months ago

 did you find any solution to it ? was actually looking for something like that ( set class element in HTML exported element ) 

mferretti - 12 years 7 months ago

Have you tried the JR forum yet? This probably needs to be broken into two pieces:

  1. Can JR do this?
  2. How can you set it in iReport?

Point one should be on the JR forum. Point two would be here. (I don't know if it's possible. It sounds entirely reasonable, but I haven't heard of it being done before.)


mdahlman - 12 years 7 months ago


1. As far as I know there is no such property yet. This list contains the id property but not a class property:

2. I guess there is some kind of workaround by assigning the first part of the ID as static string: "useThisAsAClass"+$F{uniqueID}

And then use the static string part as a class. This is far from optimal though and it would certainly be nice with a class property.



Post Edited by phantastes at 02/22/2011 19:23

phantastes - 10 years 8 months ago

1 Answer:


I haven't been on the JR forum to know if you discussed this topic there. But I just got the JR 4.0.1 release notification. It adds:

"custom property "net.sf.jasperreports.export.html.class" added at element level to allow 
specifying the CSS "class" attribute for elements when exported to HTML and XHTML/CSS format;"

As far as I can tell, this is precisely what you're looking for.


mdahlman's picture
Joined: Mar 13 2007 - 2:43am
Last seen: 8 years 10 months ago

Thanks Matt!

You guys are really good at listening to feedback! Impressive.



phantastes - 12 years 7 months ago

 just tested . 

you guys rock !

mferretti - 12 years 7 months ago


Do we have any samples for this or some more documentation ?





bansi - 12 years 6 months ago
show 1 more...


in practice, what you have to do is add  <property name="net.sf.jasperreports.export.html.class" value="YOURVALUE"/>  to the report element that you want, in HTML, to be of class="YOURVALUE". 



<reportElement x="157" y="0" width="15" height="78">

<property name="net.sf.jasperreports.export.html.class" value="verticaltext"/>



mferretti - 12 years 6 months ago