Jump to content
We've recently updated our Privacy Statement, available here ×

How to compare string value in properties Expression using ireport jasper?


sanamworld10

Recommended Posts

Ans:  I had a pretty rough time comparing string value in ireport and I got the solution which I want to share...(especially for the bigenners) 

To compare String value in "properties expression " we can write the formula as below:

1> select the field and go to properties..

2> Then go to Properties Expression and set the below 2 values::

a>Property name:   net.sf.jasperreports.export.xls.formula

b>Property value:  

"IF(AND((IF(AND(ISBLANK(A"+($V{REPORT_COUNT}+1)+"),ISBLANK(B"+($V{REPORT_COUNT}+1)+")),"+""+",(B"+($V{REPORT_COUNT}+1)+"-"+"A"+($V{REPORT_COUNT}+1)+"))<0.25 ),(OR(((D"+($V{REPORT_COUNT}+1)+")="+""T""+"),((D"+($V{REPORT_COUNT}+1)+")="+""T+1B""+"),((D"+($V{REPORT_COUNT}+1)+")="+""T+2B""+")))),"+""+",(B"+($V{REPORT_COUNT}+1)+"-"+"A"+($V{REPORT_COUNT}+1)+"))"

Explanation of above formula:

first: (ISBLANK(A"+($V{REPORT_COUNT}+1)+"),ISBLANK(B"+($V{REPORT_COUNT}+1)+")) -->It will check if the cell value is blank or not

structure is : "IF(  AND  (                (  IF(  AND(     blank check  of two cells  )       )  ) ,     (  OR((condition1),(condition2),(condition3)   )           ) ," +""+  ",else part)"

less than sign(<) is given by ---><

String comparison: "(          (D"+($V{REPORT_COUNT}+1)+")="+""T+2B""+"    )"

write within -->     "string value" and close it with quotes  (ie   +""string" " )

 

For above code to work : Create a table in sql : Create table Salary(small float,big float,activity varchar(20))

Then connect the ireport with database and fetch the fields from database : (small,big,activity)

Now design the jasper report as:

small               big            idle1            activity   

$F{small}     $F{big}     $V{idle1}     $F{activity}

 

idle1 is a variable which you have to create in : Report Inspector: fx Variables  (after creating variable "idle1" drag and drop in details part)

 

 

  

 

Link to comment
Share on other sites

  • 1 year later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

i'd like to know too as apparently:

"The method EQUALS(String) is undefined for the type String"

who wrote this............

no validation on the expression editor have to exit and run the report to check (WASTE OF TIME)

DOES NOT RUN WHEN validation underlines are not shown, repoirt just fall over at runtime  (WASTE OF TIME)

and just look at teh NOISE and clean structure of the guys query above, fancy maintaining that ? anyone? I dont...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...