Start JasperReport subreport on new page, but not when launched as main report - jasper-reports

I have a JasperReport named 'Receipt' that can be launched as a:
subreport in a Summary band, to display any receipts
main report, to display a particular receipt
How can I start a new page before any receipts, when it is used as a subreport, but suppress the new page if there are no receipts?
Setting isTitleNewPage="true" works when it is used in the subreport case, but causes the Detail band to be displayed on the second page when it is used as a main report.
Using a Break prior to the subreport means a redundant page is used if there are no receipts.

I solved it by:
Adding a Boolean isSubReport parameter to the report
in the Detail band, adding a Break, with a Print When Expression set to:
$V{PAGE_NUMBER} == 1 && $P{isSubReport}
In the parent report, passing the parameter isSubReport with value TRUE()
Feels like there should be a cleaner solution, but it seems to work.

Related

Printing the head line only on first page

I have jasper report which is created by many objects.
I want the header in one object. The object may come any where in the report.
How can i print header only on the first page of the object.
Can i use print when expression if page number equals 1.
is that page no means for whole pdf report or for only single jrxml object.
Thanks.
What does you mean anywhere in the report? If you want to print a title only once and in the first page, use the Title band in the jasper reports. No need of additional conditions required.

Parameter Value in main report is not passed to a parameter in the subreport

I need your assistant in passing a value of a parameter in the main report to the subreport. I defined a parameter in the main report which is called {?ReportNumber} and its type is Number and it is static.
In the Select Expert of the Main Report I added the below code:
{engine.reportnumber}={?ReportNumber}
This will take the value of the reportnumber from the table and it will assign it to the parameter. Each time I ran the report, the value will be different based on the retrieved data.
In the Subreport, I created again a parameter with the same name {?ReportNumber} and its type is Number and it is static.
I have added a subreport link which is {?ReportNumber} parameter and below I selected to match the {?ReportNumber} parameter which is in the subreport.
However my issue is that when I ran the report, the report is prompting me to enter the parameter of the subreport, even though I have added and assigned a value to it as I have explained in the above steps.
I am using Crystal Reports 2011
Even tried to use shared variable in the main report:
shared numbervar report_number := {engine.rptno};
report_number;
In the sub report, I create a formula ("Shared_report_number") and I placed it in the report header. It has the code:
shared numbervar report_number;
report_number;
I clicked on Select Expert and then I chose the field {engine.rptno} is equal to {#Shared_report_number}, it produces an error that : the formula cannot be used because it must be evaluated later
Kindly assist me in passing the value of the parameter from the main report to the subreport.
This prompting shows that your parameter is not link properly.
When you link the parameter. In left side, main report parameter show
1. is of sp parameter
2. is of custom report parameter
While you linking, note that you custom report with report name is joined.
Please check this below link, in UI potion of third image , right-bottom side you have to choose sub-report parameter. So check and then link.
http://blog.niklasottosson.com/?p=1137
In your case, I think your main report parameter is link with itself. not with subreport parameter.
Check this link carefully while mapping.

iReport, subreport does not appear

i'm trying to add subreport to report.
I have setted connection type to "use a connection expression" and the expression is $P{REPORT_CONNECTION}.
My subreport contains a simple query and some static text, when i test it all works good, but when i test mainreport the subreport does not appear.
I have some static text in subreport, this one should be display always, isn't true? But i can't see it...
During compilation i have no errors, and subreport path seems correct becouse a message say "subreport.jrxml already compiled.".
What can i do?
Thanks.
The solution is pass HIBERNATE_SESSION as parameter from master report to subreport.
Please Right clik on sub report and clik on open sub report if your sub report gets open then your reporyt is connect with your sub report. if subreport is not open do the right connection for that.
if your subreport is work for the parameter value with seperatly and displyes the static text and detail band values it is sure that the report will come ffrom main report.
but the report displays only static text and the text is in title or page heder, then you have to go to the report property and set the output when no data then choose diplay all section data from combo. your static text will apper from main report.
When you add a sub-report in your main report, the sub report expression will refer your locally saved sub-report path. Ex: "C:\abc\xyz.jrxml".
Now you can preview your main report containing sub-report in your ireport.
Once you publish the main report in Jasper server, the Sub report gets loaded into jasper repository and its expression becomes "repo:Repositorypath.jrxml".
Once sub-report contained report is published into Jasper repository, its path will always refers to Jasper repository path and because of this reason, you will not be able to Preview the main report in Ireport.
So, execute the report in jasper server directly once you publish the main report instead of previewing or opening the subreport in Ireport.
Thanks,
Srikanth Kattam

Subreport values are not displayed in main report

I have my main report which contains 1 subreport. When I run my main report the subreport values are not displayed in my main report, but when I run my subreport individually I can see the output in PDF format. Can anyone help me in fixing this issue?
First see the connection with right click on the report and click on open subreport if its working then clik on the subreport go to the subreport property and see the parameter passed to the subreport is correct or not if not please pass properly. also see the parameter value required for the subreport is that comming from main report.
Means : if your subreport require account_id = 5 the it must that main report passes the value 5 to the subreport.
You need to call the SubreportProcessingEventHandler and add the datasource.
Step 2: Check the properties of subreport.
If it does not need any parameters from main report. Do not add any.
The path of the repo

Need to remove Empty pages when subreport is returning no data (IReport)

I have a subreport inside a main report on a new page due to the layout. When the subreport generates no data(sql table is empty), there is a blank page generated in the mainpage. How can i omit this empty page? please help me here..
You can try to work around by using the <printWhenExpression> construct or try it with isRemoveLineWhenBlank