edeards Posted December 5, 2008 Share Posted December 5, 2008 Hi all,I'm writing a report generation system which builds pdf fragments from assorted datasources and tacks them together to form a big report. As a consequence I'm trying to generalise all my input fields in such a way that for all these jasper report fragments, I provide the same fields in a JRMapCollectionDataSource.This works fine so far.However I have a subreport in one report which needs to sum a column and place a total in the footer band. Again, this would be simple - if my fields were Integers rather than Strings!I do have a mechanism in my own code to change this - however it's something I'm prefering use as infrequently as possible, as it means I'm breaking away from my generalised interface.I cannot see any function within the iReport expression builder that allows me parse Integers from the String fields. I'm hoping there is some mechanism by which I can write my own function/expression handling code and plug it into the jasper engine. Does such a mechanism exist?Thanks for any advice! Link to comment Share on other sites More sharing options...
lucianc Posted December 5, 2008 Share Posted December 5, 2008 You can parse Strings into Integers via the standard Java method Integer.valueOf(String) (if the number format matches the format that this method expects).If you want to use your own parsing method, you can do so directly by calling the method in the report expression (i.e. com.me.MyUtils.parseIntegerString($F{field})).HTH,Lucian Link to comment Share on other sites More sharing options...
edeards Posted December 8, 2008 Author Share Posted December 8, 2008 Ah thanks Lucian.The fact that expressions in JasperReports are straight java had entirely escaped me. That makes my life far easier.Thanks! 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