2006 IR Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: Kok Hoor - kokhoor Print Page Footer Band only for the last page 2003-05-27 20:35 1. Is it possible to enter an expression to only print the page footer at the last page of the report? Can a scriptlet helps? 2. I am using JasperReports to print invoice, and want to display the Grand Total at the end. Summary Band doesn't work because I want the Grand Total to be displayed at the bottom of the last page. Is there any way to do this? 3. Consider the case of printing multiple invoices. I will then need to print the Grand Total on the end of every group (invoice group). Can this be done as well? 4. I can't use subreport, unless I am able to pass in the connection url, userid and password. Regards, Kok Hoor By: Victor Gieci - drummer RE: Print Page Footer Band only for the last page 2003-05-27 22:13 Hello. To your question about the footer on the last page -> see this thread: http://sourceforge.net/forum/message.php?msg_id=1984322. The solution is there. Cheers By: Teodor Danciu - teodord RE: Print Page Footer Band only for the last 2003-05-28 00:18 Hi, 3. Use the "evaluationTime" attribute for you Grand Total attributes. 4. If the master report receives a connection, the you can pass it further to your subreports using the built-in parameter REPORT_CONNECTION. Check the "subreport" sample provided. Thank you, Teodor By: Teodor Danciu - teodord RE: Print Page Footer Band only for the last 2003-05-28 00:20 Hi, 3. Use the "evaluationTime" attribute for you Grand Total attributes. 4. If the master report receives a connection, the you can pass it further to your subreports using the built-in parameter REPORT_CONNECTION. Check the "subreport" sample provided. Thank you, Teodor By: Kok Hoor - kokhoor RE: Print Page Footer Band only for the last 2003-05-28 22:25 Thanks for your replies. I will work on it to make sure it works, and post a result on that. However, just two quick notes: 1. It will be great if we can have more than one Page Header and more than one Page Footer. This way, we can print different page footer based on the expression. 2. If we add an init method to JRDataSource: public void init() and allow the JRDataSource to read parameters and fields, just like Scriptlets: getFieldValue, getParameterValue, getVariableValue, setData, setVariableValue Then the first time we access the JRDataSource, we call the init function, then we can easily extend JRDataSource to actually allow us to populate data into sub-reports without resorting to using existing connection. Just my 2 cents. Regards, Kok Hoor By: Kok Hoor - kokhoor RE: Print Page Footer Band only for the last page 2003-05-29 04:15 Hi all, JasperReports, plus the JasperReports forum is really great!!! Thanks to you guys for being so helpful. I have solved my problem (at least half of it). I am writing what I did right now, hopefully it can help as a guide for newbies. There might be a better approach, but anyway: 1. I wrote a scriptlet, which I called the FooterFixScriptlet. It is derived from JRDefaultScriptlet, and consist of only 1 function: public String setValue(String var, Object val) throws JRScriptletException { System.out.println("Set Value : " + var + " : " + val); setVariableValue("FooterFix", val); return ""; } 2. Next, I created a variable, which is 'System calculated', that will be used by the Page Footer "printWhen" expression to determine whether the footer should be printed or not: <variable name="FooterFix" class="java.lang.Boolean" resetType="Report" calculation="System"> <variableExpression><![CDATA[boolean.FALSE]]></variableExpression> <initialValueExpression><![CDATA[boolean.FALSE]]></initialValueExpression> </variable> 3. Thirdly, I created a dummy group, GroupHeader is 0 in height and GroupFooter is 0 in height. There is a textfield (x,y, width, height = 0) in the dummy group with the expression: ( (report.FooterFixScriptlet) ((JRFillParameter)parsm.get(JRParameter.REPORT_SCRIPTLET)).getValue()). setValue("FooterFix", Boolean.TRUE); 4. The "printWhen" expression for Page Footer would be: $V{FooterFix} However, I think that a more elegant approach would be to have a System set variable, say $V{NO_MORE_RECORDS} that is automatically set to false when there are no more rows in the recordset passed in (can we have that feature in JasperReports?). Or perhaps, an additional call to the Scriptlet? Another possibility is to actually have the ability to have the option of printing anything such as a group footer, or even the summary at the end of the report. I used this option in Crystal Reports. Not comparing really, but only a suggestion. Lastly, I was looking at the possibility of creating a solution for printing only the page footer whenever the end of a group is encountered. (In my case, it is for the purpose of batch printing multiple invoices). My approach is to set the FooterFix variable to false in the page footer, so that everytime a page footer is printed, subsequent page footer (next page) will not be printed unless an end of group is met in the next page. However, this does not work as soon as I have the 'isStartNewPage' = true for the group, I don't quite understand why. I'll research more on this and try to post more info. Anyway, thanks. At least I got part of my job done. Thanks everybody, Thanks JasperReports. This is one very cool open-source project. My only concern is how well the JasperReport can churn out big reports, since there is no PDF-streaming. Anybody uses JasperReports to print large reports? Regards, Kok Hoor 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