tadan Posted October 10, 2007 Share Posted October 10, 2007 hi allI'm newbie of iReport, and I would like to take a field of my db (is an integer value), divided this by 100 and post the result in my report.Could anyone help me please?Many ThanksFrancesco Link to comment Share on other sites More sharing options...
jmurray Posted October 11, 2007 Share Posted October 11, 2007 1) You can do it in your source query: SELECT FIELDNAME/100 as FIELDNAME FROM SOMEWHERE and set you TextField Expression to be simply $F{FIELDNAME}. or 2) you can do it your report TextField by setting the TextField Expression to something like new java.lang.Double($F{FIELDNAME}.doubleValue()/100) Either way you will need the TextField to be defined as a java.lang.Double or java.math.BigDecimal, depending on the size of your data. You can set the output format using a variation on the "#,##0.00" format string. For example, "#,##0" will display integer values. Have fun. Link to comment Share on other sites More sharing options...
tadan Posted October 11, 2007 Author Share Posted October 11, 2007 Hi many thanks for you're response.If I try to follow the 2nd way, when I compile the report appairs an error that says:"the method DoubleValue() is undefined for the type Integer".I think this is referred to my field that is an integer but I'm not sure ... could you give me more help?Many thanks all the best Francesco Link to comment Share on other sites More sharing options...
jmurray Posted October 12, 2007 Share Posted October 12, 2007 You problem is that java is case sensitive: use doubleValue() not DoubleValue(). If your field is an Integer then you can always grab its intValue(), like this: new java.lang.Double($F{FIELDNAME}.intValue()/100) You TextField is still a java.lang.Double. You can force it to be a java.lang.Integer if you want, just recast the result like this: new java.lang.Integer(new java.lang.Double($F{FIELDNAME}.intValue()/100).intValue()) .Post edited by: jmurray, at: 2007/10/11 22:43 Link to comment Share on other sites More sharing options...
tadan Posted October 17, 2007 Author Share Posted October 17, 2007 Dear jmurray,matny thanks for you're support I've resolved 100%!Many thanks again. All the best :-) Francesco 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