JasperReports, PrintWhenExpression and RemoveLineWhenBlank → Strange Behaviour - jasper-reports

I have a problem with JasperReports when using printWhenExpression and RemoveWhenBlank inside a subreport.
To reproduce this problem, I made a simple example using one master report and two subreport.
The first subreport, let's call it the static subreport, contains two Static Text components in the title band (Label 1 on the first line, Label 3 on the second), both have the Position Type attribute set to Float. The title band Split Type attribute is set to "Immediate".
The dynamic subreport have three Static text components (Label 1 on the 1st line, Label 2 on the second and Label 3 on the third), all of them have the Position Type set to Float. But Label 2 has PrintWhenExpression set to Boolean.FALSE and RemoveLineWhenBlank set to TRUE. So Label 2 is hidden and Label 3 is moved to Label 2's place under Label 1.
So basically the dynamic subreport and the static one have the same structure and should behave the same way when printed inside a report. But that's not the case in this little example.
In the master report I'm using a subreport component inside the detail band ( the split type of the detail band is set to Immediate ) and using a JREmptyDataSource with 90 empty rows. When pointing the subreport component to the static subreport, the pdf output generated by jasperreports is corrrect. But when using the dynamic subreport, jasperreports leaves an empty space (that is used when using the static subreport) at the end of the first page and jumps to the next page to print Label 3.
In the real case that I have a problem with, I have a subreport that contains more than 20 lines with Static Text and Text Field components, most to them with printWhenExpression set to a field or a parameter and RemoveLineWhenBlank set to TRUE. When producing the pdf output in some cases I have that specific subreport (which should occupy just  a third of a page) spanning one page and a half with a lot of space spread between the visible lines in the subreport. And I think the combination of RemoveLineWenBlank and PrintWhenExpression is what's causing the problem.
 
So what I want know is if this is a bug or just me missing something in the documentation.
Here is a link to the post I made at the JasperReports forum, it contains the templates for the master report and the two subreports, plus two pdfs generated by jasperreports and screenshots showing the layout of the subreports: link
Thanks in advance for your help.

Related

Jaspersoft studio calculate variables before detail band

Jaspersoft studio 6.2.
The report below, there are 3 bands: title, detail, and summary. Detail is in the middle. Look at "Activated staff" on the top on title band, it used a variable (activatedstaffcount1) as expression. The variable sum all activated staff counts in the detail. However it shows null. The bottom one is in the summary band and used the same variable but it shows correct number. The middle section is the data (detail band). I want to show aggregated result before the display data(detail band), how can I do it?
Try to set also Evaluation time in the text field which contains that variable to the "Report".
If the text field is outside of the table - try to return value into the parameter back from dataset and display that parameter at the end of report evaluation.

how to get rid of the white space when hiding a subreport ssrs2008?

I am using SSRS-2008. I am using a subreport named SubReport1 in my main report named MainReport1.
When SubReport1 has no rows, I get white-space in place of SubReport1in MainReport1.
How can i get rid of this?
The subreport will be displayed in main report with the properties mentioned in the subreport itself. So, if reduce the row height, it will not affect the report display if there exist a value. In all other cases, you will not see a blank space over there in the main report. (The row boundaries also could set to 'None' values in main report)
Select the row properties -> under 'Layout' section, you could find the 'Height' parameter. Provide value for this parameter as 0.07938cm

Passing Value from Sub Report To MainReport on Crystal Reports

I'm currently having a problem with regards on Crystal Report Shared Variable. this is my situation.
I have a Report consist of multiple sub reports (and of course the main report). i need to expose a value in main report from Sub Report, but the problem is i need to Display it before the sub report was rendered. Please see the image below:
As you can see the image above, i need to display the value below (Sub report with RED encircle with VALUE) on the TOP (Red encircle without value).
I used Shared Variable but i think it will not work since the TOP will be first rendered (where i need to display the Value from subreport) before the Below(where i need to get the value).
Is it possible?
The section that displays the value has already been rendered by the time the other section sets the value of the shared variable.
Two options:
add a second instance of the subreport to a section that precedes the section when you want to display its value; you won't be able to suppress either the section or the subreport, so you will need to make the subreport as small as possible and change the font colors to white
use a sql-expression field to calculate the desired value and avoid the subreport complexity altogether

JasperReports: Multiple sub-reports inside a master-report

I would desperately need some help to achieve the following:
Create a master-report.jrxml, which includes a table of content and the corresponding sub-reports
These sub-reports all contain a different chart with different data query, which can be bigger than one page
Every page which includes a sub-report must show some static frame with dynamic content like the current sub-report's name and page X of Y
My approach so far was, to create a sub-report.jrxml for each of my required charts (I put chart in the sub-report's summary band). Then I created a MasterReport.jrxml with my static frame which included the sub-reports in the summary band. I expected/hoped that JasperReport would render a the according sub-report after each other, but it just overdraws on the same page.
How can I configure my report, to display the sub-reports after each other on new pages?
Any help with this, would be highly appreciated.
Try with subReports in a detail band and subRepport element has "Run to bottom" property which, if set to true, will make subReport take the whole page and push next item on a new page. There is also a page break element in JasperReports if "Run to bottom" doesn't work for you . For static content on each page use page header/footer bands.

Border in Detail band

I have a question about how border should display in detail band, and I would like to get some help.
Say, a column in detail band that might have LOTS data, by lots, I meant sometimes a single record might actually took 2~3 page to display.
Now customer ask that we should make report always display bottom line of the border as long as it meets end of page (even this record its not end yet)
What I tried:
Make a column footer with 1px height line.
Set "Floating column footer" to TRUE.
Result : It works great, but this line will make extra empty space at end of the table if there is a Summary band after the column footer. I think I am close, but I just can't get rid of the strange empty space
Make a Frame with border, set "Print when detail overflow" to TRUE then put everything in detail band into this frame.
Result : Not work as I expected :(
Since this report contains not just a table in detail band, and the height of the table are random. Tricks like a border in Background or Page Footer are not suitable here
What else can I do ?
There is a PrintWhenExpression trick that can help with the page footer:
How to hide Page X / Y when report is 1 page ? - JasperForge Forum
The trick is to put a flag in the Report Parameter Map, then use the flag to decide whether text (or fields, lines, etc.) should be printed.
To use a line in Page Footer there will always be some pages with extra line. In this case, the report is always starting from page 1, and the table in the report always end before printing the Summary band. That means, the line is no longer necessary as long as Summary band has been reached. Thus:
Add a line in Page Footer with PrintWhenExpression :
new Boolean(!(Boolean.TRUE).equals($P{REPORT_PARAMETERS_MAP}.get("stopFlag")))
Then make a dummy textField in Summary band with PrintWhenExpression like this :
$P{REPORT_PARAMETERS_MAP}.put("stopFlag",Boolean.TRUE)
This trick works, but might need some tweaking for different layouts.
The option given by Dave is right.
If you care about the space still being used, then set the band and textfield heights to zero.
In my case using Dave's option worked (and I needed no extra space to be used).
I put this as PrintWhenExpression in the fields I just wanted to show in the last page:
$P{REPORT_PARAMETERS_MAP}.get("lastPage")!=null
And this as PrintWhenExpression in a 0-height textfield in the 0-heigth summary band:
$P{REPORT_PARAMETERS_MAP}.put("lastPage",":)")
When it comes to page termination the options are limited. Its made even hard because if you have items that do not display when null it still assumes that space is used.
I would stick with messing around with the column footer or page footer as your best options.