nephalem Posted June 24, 2011 Share Posted June 24, 2011 Hello,I am pretty new to Jasper Reports and I try to do some reporting from a MySQL Database in iReport.I managed to split the String the way i needed it (get rid of all the unimportant text etc.) so it contains nothing but numbers.The Problem is: How do i convert the (String) numbers to a "real" number i can do calculations with in groovy?For Numbers there are various methods but i didnt see any easy way to convert a String to an Int or Double. Hope you can help me. Many thanks in adviceNephalem Link to comment Share on other sites More sharing options...
cbarlow3 Posted June 24, 2011 Share Posted June 24, 2011 I just tried Integer.parseInt($F{StringField}), and it worked fine for me. Hope that helps. Carl Link to comment Share on other sites More sharing options...
adiboing Posted June 27, 2011 Share Posted June 27, 2011 Question is my sugesstion right that I can implement more functions to iReports Expression?I found the function praseInt() but this function and others like, .getInteger(String) or valueOf(String) is just returning an null.... do you know why? Thats my expression in the properties of a Variable called intTest... and the field Gesamt Brutto is a String containing numbers as string...: $V{intTest}.parseInt($F{Gesamt Brutto})$V{intTest}.valueOf($F{Gesamt Brutto})$V{intTest}.getInteger($F{Gesamt Brutto}) everything is not working... I'm using Groovy =/Post Edited by adiboing at 06/27/2011 07:00 Link to comment Share on other sites More sharing options...
cbarlow3 Posted June 27, 2011 Share Posted June 27, 2011 My guess is that the problem is that you are calling static functions of the class Integer and expecting it fill in the value of your Integer variable. Assuming this is the "Variable Expression" property of your $V{intTest} variable, you don't need to put the name of your variable in the expression. Just put an expression that will evaluate to the value you want iReport to put in your variable. In the case of a static method from the class Integer, just replace your $V{intTest} with the name of the class:$V{intTest} property panel: Variable Expression: Integer.parseInt($F{Gesamt Brutto}) Carl Link to comment Share on other sites More sharing options...
nephalem Posted June 29, 2011 Author Share Posted June 29, 2011 i solved my problem by using $V{Variable}.toInteger() which returns the string as Integer. unfortunately the build-in editor didnt show me this possibility but google did Link to comment Share on other sites More sharing options...
shteng87 Posted July 4, 2012 Share Posted July 4, 2012 deleted Post Edited by shteng87 at 07/06/2012 03:09 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now