How can I achieve this? I also tried using "print when expression" with condition
new Boolean($V{PAGE_NUMBER}.intValue() < $V{PAGE_COUNT}.intValue())
but sadly it does not work. Please help me.
This print when expression works fine for me $V{PAGE_NUMBER}<$V{PAGE_COUNT}. It works when applied to either the column footer band or the footer band element (I used static text).
Comparing PAGE_NUMBER and PAGE_COUNT is like comparing apples and oranges.
The Built-In Variables
PAGE_NUMBER: At every iteration it contains the number of the pages that compose the report.
PAGE_COUNT: Contains the number of record processed in the current page
To answer the question: JasperReports knows a band type "Last Page Footer" (wiki description) to define a different footer on the last page.
(Your problem might already be solved. But I stumbled upon this two year old question while having a similar issue and wanted to leave a hint, that one should not compare those variables.)
Related
How do you check to see if the current printed page is actually the last printed page?
I have tried the following:
$V{currentPage}.intValue() == $V{totalNumberOfPages} ?
Boolean.TRUE : Boolean.FALSE
waited for a long time .. but no reply from Stackoverflow...
Anyway i found my solution..
First in your summary band put this line
<printWhenExpression><![CDATA[new Boolean($P{REPORT_PARAMETERS_MAP}.put("LastPageNumber",$V{PAGE_NUMBER}).equals("dummyPrintWhen"))]]></printWhenExpression>
Remember this above line must be only in the summary band of the report.
After that you can compare this parameter at any point of time in your report to find last page number .
For Example
<printWhenExpression><![CDATA[new Boolean(!$V{PAGE_NUMBER}.equals($P{REPORT_PARAMETERS_MAP}.get("LastPageNumber")))]]></printWhenExpression>
With the following Print When Expression the summary band gets printed again:
new Boolean(($P{REPORT_PARAMETERS_MAP}.put(
"LastPageNumber",$V{PAGE_NUMBER}).equals("dummyPrintWhen")) ||
Boolean.TRUE)
You can also use containskey tot test for the existance of the key:
new Boolean(!$P{REPORT_PARAMETERS_MAP}.containsKey("LastPageNumber"))
Nummeric expressions also work, this expression evaluates to true on every page except the one on which the parameter is set:
new Boolean($P{REPORT_PARAMETERS_MAP}.get("LastPageNumber") < $V{PAGE_NUMBER})
My problem was that I created multiple group footers for several crosstabs at the end of my report, with a constant as the group expression so they get printed only once. By setting the parameter in the first footer I can now finally surpress the column headers without resorting to subreports. Great work!!
Berry.
unfortunately your approach didn't worked for me i dont know why.. there are some stuff about your code that are error-prone like this
<![CDATA[new Boolean($P{REPORT_PARAMETERS_MAP}.put("LastPageNumber",$V{PAGE_NUMBER}).equals("dummyPrintWhen"))]]></printWhenExpression>
i think in fact that the Summary Band is called only once but you have a bad programming practice in this because if there is not key associate with the KEY in the MAP it will return null and the you call the method equals on it you would receive NULLPOINTEREXCEPTION but i think not in this case.
you should reverse like this
<![CDATA[new Boolean("dummyPrintWhen".equals($P{REPORT_PARAMETERS_MAP}.put("LastPageNumber",$V{PAGE_NUMBER})))]]></printWhenExpression>
the workaround i used on this question is the following.
1). create a parameter in jasperreports
parameter name="totalRecordsOnReport" class="java.lang.Integer"
2). pass the totals records of your detail as parameter.
HashMap<Object,Object>parameters=....
parameters.put("totalRecordsOnReport",yourDetailRowCount);
i need to print some stuff only in the last page below the detail and i use this code.
component print when expression
$V{REPORT_COUNT}.equals($P{totalRecordsOnReport})
and prints in the last page.
I need to print the report footer before the group header/footer in ActiveReports 6. My code in report footer requires calculation from the group header/footer, so instead of moving all the controls to report header and do massive changes to code, I wonder if there's a quick way to just rearrange the page at print time.
I currently have:
rhMain (reportheader) for report cover page
gfVehicle (groupfooter) for detail on each vehicle, summary data is also calculated and stored here for each vehicle to be used in report summary
rfMain (reportfooter) for report summary
What I need to be arranged:
rhMain cover page
rfMain summary page
gfVehicle detail on each vehicle
What I have tried is move all the summary stuff to rhMain and during rfMain_format, I change the value of the controls in rhMain. This failed probably because rhMain is already rendered at this point.
Any other ideas?
There is no way to rearrange the sections during printing. The sections are designed to be rendered in a specific order and it cannot be changed. If you can provide some detailed information about your use case we may try suggesting some workaround. You can post your questions to ActiveReports support forums.
Can you please explain your scenario so we can try to help based on it. In general a report footer is nothing but a "group-footer" for the whole report (that is not bound, so would it help to replace the report-header/footer with an outside group header/footer.
Please include an image of what you're trying to do so we help further.
Issam Elbaytam
Grapecity.
I have 20 columns on report. We have provided user to exclude columns which don't want in report. So we made hidden.
Problem is when I get report then any last column on page gets appeared some part on 1 page & some part on another page.
Can you please help.
hi i hope i understand your question correctly. you want to avoid page breake for a tablix? mark the tablix go to properies and check the PageBreak Options for me tDisabled = True works to render all informations in one page.
if it is still not working check your pagelayout in report --> report properties
also i remember there was a InteractiveHeight Option somewhere that should be set to 0.
More than a full day gone and i still can't find a solution...
I am creating a report which will be used to print out an exam paper(Crystal Reports with VS 2010). All exams have more than one related unit and all units have their own questions.
So i have created a sub report with the units and questions and added to the main reports' Details section which formatted as multicolumn. I have generated the report which seems like below.
http://www.avekon.com/tmp/examprintscreen0.png
Everything is fine until now. But when i want to add the unit titles (which are in the subreport),they are displayed as headers of each column. I want to display the unit title as centered on the top of each page, like below.
http://www.avekon.com/tmp/examprintscreen.png
Tried to add a header to main report and update it from subreport. NOT WORKED! Because the variables are not while the subreport is looping.
Tried to format other sections as multi column. NOT POSSIBLE as i see.
Tried to insert sub report into sub report. NOT POSSIBLE again.
and i have tried a lot of other logical and illogical ways but no success at the end. It should be easy but i can not find the right way. Please help, really important!
Remove the multi-column formatting from the main report and instead, format the sub-report as multi-column.
This should do the trick.
I am using iReport version 4.0.1. I am facing a problem in which I want to display some information that must come on the 2nd page only. So, its neither a FOOTER nor a LAST-PAGE-FOOTER. I am using iReport for generating the jrxml files and the design looks something like below.
{HEADER}
{DETAIL-BAND-1} Remarks: Till this point my 1st page finishes
{DETAIL-BAND-2} Remarks: This is coming from a sub-report
{DETAIL-BAND-3} Remarks : This is coming from a sub-report
Some Random Empty Space Is Left
{DETAIL-BAND-4} Remarks: This is where my 2nd page footer needs to come.
.
.
.
.
{Lots of Bands}
.
.
{MAIN-REPORT-FINISHES}
So, I want the footer (actually it is not a footer, its some detail that only need to come on the 2nd page of the pdf generated by JR) to be fixed relative to the top of the page in which it is being printed. Is there a way to do that?
Thanks
Try to use the property "Print When Expression" and then you can use a variable that already exists in your iReport called PAGE_COUNT and it will be printed only when this expression is true.