2005 IR Help Posted August 22, 2006 Share Posted August 22, 2006 By: Craig O'Shannessy - shanness Subreports to allow reuse? 2004-02-08 23:03 Hi, I'm having a problem getting re-use. I'll try to explain. A B C D E F G H I J K L M Imagine that columns C-M are common on about 5 reports, but column A and B change, as does the SQL. I thought I could do this (make a subreport with C-M details + page headers + page footers (totals)), but it doesn't seem to work this way :( Would I have to make a separate subreport for each "band" of this (e.g. one subreport for the C-M column headers, another one for the C-M detail band, and another for the totals?) If so, this seems pretty ugly, and would make maintenance a nightmare (move column D across, have to edit three+ .xml files). Any other ideas? The only other thing I can think of is making a single report and passing in parameters to change behaviour, but this seems pretty ugly too, although it might be the nicest solution. Hope this makes sense. Thanks in advance, Craig By: Teodor Danciu - teodord RE: Subreports to allow reuse? 2004-02-14 04:49 Hi, I think you could make a report template containig all your columns. Each column would need to have a <printWhenExpression> based on some parameters that sould decide if it prints or not. Then, before launching the report, you should alter it to move columns to the right or modify their with to accomodate the columns that will be missing. Moving elements on the X axis or modifying their width has the advantage that it does not require report design recompilation and hence you gain speed, as oposed to complete report template build-up from scratch every time. Check the "alterdesign" sample to see how you could move elements around. I hope this helps. Teodor By: Craig O'Shannessy - shanness RE: Subreports to allow reuse? 2004-02-19 04:19 THANKYOU THANKYOU THANKYOU! Teodor, this is perfect, just what I was after! I had no idea that I could do this in Jasper! For anyone searching, here is a bit of code from AlterDesignApp.java rectangle = (JRRectangle)jasperReport.getTitle().getElementByKey("third.rectangle"); rectangle.setForecolor(new Color((int)(16000000 * Math.random()))); rectangle.setBackcolor(new Color((int)(16000000 * Math.random()))); I Don't spose you have any plans to update the Ultimate Guide ? It doesn't document the key= attribute on the ReportElecment tag, and subreports was a bit hard to understand at first. Thanks for you help, this allows me to do relative positioning pretty easily I think (set up an collection of elements, and pull them all left by a certain amount). Craig 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