fchalmeau Posted June 22, 2011 Share Posted June 22, 2011 Hi, In my company, we are using the combo iReport/JasperReport for some times now, we are very happy with it and we want to improve our reports to a next step of flexibility. What I got is a master report (an Invoice) that contains a table as a subreport (products). This table contains many columns (Product Code | Product Description | Quantity | Unit Price | Total Price | Taxes), and sometimes all those columns are too much. So, what I want to do is to add layout options in order to choose the columns that I actually want to display. And of course, I want my table to still looks good, that means keeping the same size for the whole table, and stretch columns B when column C is hidden for instance. I've checked the last iReport, I was able to hide/show columns in my table (like with the 'printWhenExpression' option), but the columns doesn't resize themselves to occupied the free space. Is it possible to do such a thing with iReport and JasperReport ?Post Edited by fchalmeau at 06/22/2011 13:10 Link to comment Share on other sites More sharing options...
neozerabbit Posted June 23, 2011 Share Posted June 23, 2011 As you said you can hide a column using the propery "Print when expression" but it will let you a blanc column ( no automatics resizing, it's a lack of Jasper, I confim) There a re several ways to solve you problem :- make all the sub reports combination you need and depending the case, use the one you need (heavy and bad way I think)- superpose field in you template and use print expression to display fields you want- generate dynamically your template in Java Like you i use IReport + Jasper reports, but I use IReport for first desing and the main things are done dynamically in Java : A mix between the second and the third proposition.Japser Soft propose a tool (to buy) which can deal with table columns : "Column Manager"I've never tried it.Post Edited by neozerabbit at 06/23/2011 08:06 Link to comment Share on other sites More sharing options...
augarte Posted June 23, 2011 Share Posted June 23, 2011 You can also use DynamicJasper combined with jasper to add columns dinamically depending the ones you want to add in each case. I have made a project with this tool and have a java app that generates different reports depending on the data you want to add to it. Check it out: http://dynamicjasper.com/ Link to comment Share on other sites More sharing options...
fchalmeau Posted June 23, 2011 Author Share Posted June 23, 2011 Thanks for your very complete answer :) There a re several ways to solve you problem : - make all the sub reports combination you need and depending the case, use the one you need (heavy and bad way I think) Yes, I've though about that solution but with let's say 5 columns, that means doing 32 subreports. And that's not something we are wiling to do :D. - superpose field in you template and use print expression to display fields you want Seems clever, I haven't though about that one. Like 'Russian Dolls', with each fields going from a starting position to the end of the tab ? My table will looks good since all the border and columns lines will be ok, but I guess the content of each column won't use the free space since I won't be able to stretch the fields. Or content will overlap each other. - generate dynamically your template in Java Like you i use IReport + Jasper reports, but I use IReport for first desing and the main things are done dynamically in Java : A mix between the second and the third proposition. Yes, we've though about that one too, but currently we haven't cross the gap between just running pre-compiled reports and edit+compile at runtime. But it seems this will be our next step if we want some high level layout configuration options. Japser Soft propose a tool (to buy) which can deal with table columns : "Column Manager" I've never tried it. Thanks for the info ! I will look at that. Link to comment Share on other sites More sharing options...
fchalmeau Posted June 23, 2011 Author Share Posted June 23, 2011 Thanks about Dynamic Jasper too. I will give it a look. Link to comment Share on other sites More sharing options...
neozerabbit Posted June 23, 2011 Share Posted June 23, 2011 You spoke about precompiled reports. I do something like that. - I get a stream from the "jrxml" file (it allows me to set my jrxml file out of my jars and modify / deliver them at on runtime)- I edit and modify the report design if necessary (move, hide field, add or remove sections)- I compile my reports at runtime- I pass my reports as parameter to Jasper (Allows me to inject what ever report I want) Here a small sample// Load and compileinputStreamTitle = new FileInputStream(workingDir+ReportFile.POST_TRADE_TITLE.value());JasperReport reportTitle = JasperCompileManager.compileReport(inputStreamTitle);.....JRDataSource titleDataSource = ........... // - Report parameters Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("titleReport", reportTitle); parameters.put("titleDataSourcet", titleDatasource);....... JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource); IN FACT : my master report is only a heavy container for all sub reports. JRXMLfiles are passed to the master report as JasperReport Object. Same for data souces, execution parameters.You just have to define theese parameters in your master report and use them in your sub reports definition One more tip : My report does not execute any SQL. Data retreive is done in java. Data Sources are build and set (as parameters) before calling the report. Link to comment Share on other sites More sharing options...
srinu.ydlp Posted July 24, 2014 Share Posted July 24, 2014 I am also looking for same thing. Can you please send me some code that how to add columns to designed Jrxml file. Thanks, Link to comment Share on other sites More sharing options...
Eldar7 Posted March 21, 2017 Share Posted March 21, 2017 Is there any changes in new version of Jasper Library / Jasper Studio? 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