I need subreport just for getting some value (return value). Is it possible to hide subreport but stay it runnable? - jasper-reports

I have a report with a sub-report. The sub-report is in the details band. And I'm getting some return values from that sub-report. I want to hide the sub-report from the details band when the report is generating (even though sub-report is empty or not). But I want to receive the return value even if the report is hidden. Is there any way to achieve this?
I have tried new Boolean(false) in Print When Expression of the sub-report. But then the main report can't receive sub report's return value.
I'm using iReport 5.6.0

The way I achieved that,
I did set the font size of the subreport elements to "0" and the band heights to "0"
So the subreport doesn't need much space so report page size can be decreased too.

Related

How to fix height of subreport in master report?

I currently have a subreport within a master report. The Master report has to fit on an A4 page and as a result, I need to have a static height for the subreport as well.
The subreport which is in the "Title" band, takes in a list of text and writes them line by line. The text fields within this subreport have the flag: "stretch on overflow" Therefore, the height of the subreport is dynamic depending on the number of items in the list and whether the text fields were stretched or not.
The data passed into the subreport does not all need to be displayed. I simply want to display as much data as will fit and truncate or ignore the rest of the data.
Is there any way to have a fixed height for the subreport? I don't want it to overflow OR to show up on another page. I just want it to truncate or ignore the rest of the data within the list.
yes, if you set the stretch type to 'No Stretch' as an attribute for your subreport in the master report. Additionally, you can set your textfields isStretchWithOverflow to false.
Further information: JasperReports - Stretch Sample

How to pass variable's value from subreport to main report and show/hide detail band on the basis of that value in iReportDesigner Jasper Reports?

I am storing Value of one field in a variable in subreport. This variable I am returning to Main report. On the basis of this value I want to show/hide detail band 2. But I am not able to implement this as the value returned by the subreport is always Null which is a shock to me as when I am displaying the same value in subreport itself it is giving me 2 (integer). Please help me out with this.
For the First part of your question
The value returned by the subreport is always Null
In your Main report please cross check the following things.
You return variables from your sub report as in specified in here.
If the subreport and the text field in which you're using the returned value are placed on the same band, you need to set evaluationTime="Band" for the text field.
For the later part of your question,
I want to show/hide detail band 2
Using the report inspector, select detail band 2.
Access the properties of the band, using the properties tab.
You can find the property PrintWhenExpression.
Edit its value to hide/display detail band 2.
The second part of the answer works on the following logic
PrintWhenExpression will be evaluated at the start of the band rendering process, before starting to render the elements.
So, if the sub-report too is in the same band, detail band 2 in your case, this method would not hold good.

How to suppress on-demand subreport in crystal reports?

In my report there is an on demand subreport. The subreport is sometimes empty and in these cases i want it to be suppressed (i.e. the caption should not be visible)
Is this possible?
I tried using the checkbox under subreport -> "suppress empty subreport". it doesnt work however.
Thanks
"Suppress empty subreport" will have no effect on an on-demand subreport - these are only run on demand, and until they have been run it is impossible to tell whether or not they will be empty.
If there is enough information in the main report to be able to tell whether the subreport will be empty - for example, if the subreport is a transaction breakdown and the main report includes the total transaction value, so that a total transaction value of 0 indicates that there will be no data in the subreport - then you can select Format Subreport in the main report section and conditionally suppress the subreport in the Common tab of the Format Editor dialog.

Jasper Reports: How can i have multiple growing subreports in a report?

My Requirement is to show two sub reports in a Report. What I am doing is, I have created two sub-reports and put that into a report.
But the issue is that, both the sub reports are growing (i.e. their height is not static as the number of records are variable). I just want the second sub=report to appear after the end of first sub-report. How can I achieve the same?
You can use the option "Position Type" by selecting "Float" as the value. So based on the first reports size the second one will be adjusted.
Regards,
Raveendra Mutyala
You could put the second subreport inside the first subreport, in the page footer. The footer moves down when the detail band grows, so the subreport should always end up underneath the content of the first subreport.
Cheers,
Alexander
Try to add detail band as many as your subreport to your main report (You can right click the detail band and choose "Add another detail band"). And place each subreport on every detail band that you make.
Detail band have ability to shrink and grow depend on your data row and it will fit nicely to your report.

Inclusion and exclusion of subreports (iReport-JasperReports)

I need to include or exclude a subreport based on a condition. I'm using iReport to create JasperReports. I.e., if a subreport has values, I need to include that subreport, otherwise not. Can anyone please send a sample or tell me how to resolve this.
you can in the master report get data from your data source that allows you to identify if the subreport should be included, then use the 'printWhenExpression' field on the subreport element to check that data.
I use this regularly - for example the printWhenExpression field may contain:
new Boolean($F{TOTAL_STATS}.intValue() != 0)
where TOTAL_STATS is from the master report's database query. If non-zero we show a subreport detailing some data.
From my knowledge, if there aren't any data printed in the subreport, Jasper eliminates the blank space. In other words, if your subreport would normally occupy half a page, but there is no data, then the empty space is eliminated. I'm not sure this is what you mean by including or excluding the report.
Another solution would be to place the subreport in the main report, and from right-click ->properties -> Subreport tab, you select the "Subreport condition" tab and write your condition there. If the condition is true, the content of the subreport will be printed, otherwise it won't be printed.
Jamie Love's answer about "printWhenExpression" is on target.
if there aren't any data printed in the subreport, Jasper eliminates the blank space
Actually, at least in JasperReports 3.7.0 there is a subreport property "Remove Line When Blank" that controls that behavior. By default - at least when I use iReport - that parameter is off.
WEG