0

I have one query from my databse like that:

select name, age from Person

I did the report already, but... How can I show one table like this? : Plnkr

The idea that I can show all persons with age > 30 with row in other color and the age < 30 in white color.

How can I custom a row in JasperReports? Is it possible?

Thanks for help.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Yego
  • 1
  • 1
  • `Is it possible?` - Yes. You need to apply *conditional style* – Alex K Jul 26 '17 at 20:57
  • @AlexK Thanks, I was looking wrong :( ... I have solved my question. – Yego Jul 26 '17 at 22:30
  • @alex-k I have this, <![CDATA[$F{grade}<'3']]> I am comparing one String, yes I know but the bd returns me for instance: 3, 4, A, R. They are grades, when I did this in TIBCO Jaspersoft Studio-6.3.1 It works fine!. But when I put my report to compilation in java, the <![CDATA[$F{grade}<'3']]> doesn´t work bcz The operator >= is undefined for the argument type(s) String, char. How can I handle this in JasperReport?? Any idea? – Yego Jul 27 '17 at 21:05
  • You should cast String to Number (Integer, for example). [How to convert a String to an int in Java?](https://stackoverflow.com/q/5585779/876298). The expression will be like this: `<![CDATA[Integer.valueOf($F{grade}) < 3]]>`. In case you have not only numbers you can use some Java code, for example like at this post: [How to check if a String is numeric in Java](https://stackoverflow.com/q/1102891/876298). The expression will be like this: `NumberUtils.isNumber($F{grade}) ? Integer.valueOf($F{grade}) < 3 : false` – Alex K Jul 27 '17 at 21:31
  • @alex-k Thanks for your explanation I get it. But where can I import my function that validate if my `NumberUtils.isNumber($F{grade})` inside my .jrxml ? of course I know that is from here [NumberUtils](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/math/NumberUtils.html) but I was searching for how import a class inside report but the options in internet don't work for my case. I tried to put the dependency inside my pom.xml, bcz my proj is a maven proj, but this doesn't works still. I appreciate your answer!. – Yego Jul 28 '17 at 20:22
  • Yes, inside *jrxml*. You should use import like this: ``. [NumberUtils.isNumber(String)](https://commons.apache.org/proper/commons-lang/javadocs/api-3.4/org/apache/commons/lang3/math/NumberUtils.html#isNumber(java.lang.String)). You should also add *jar* at classpath – Alex K Jul 28 '17 at 21:11
  • @alex-k perfect!! My app works. I just had to change Integer to `Double.valueOf($F{grade}) < 3` because the db also was returning doubles. Thank you so much for your help. Greetings. – Yego Jul 31 '17 at 19:58
  • You are welcome ) – Alex K Jul 31 '17 at 22:22

0 Answers0