I created a main report and subreport with Jasper. From main report I am sending 2 parameters (Value A and Value B) to the sub report which either one can be 0. if one parameter gets 0 it needs to get hide.
I am using <printWhenExpression> and isRemoveLineWhenBlank="true" attributes to hide these elements. They are hiding properly according to the parameters, but if Value A get 0 there will be space in between KKK and Value B.
for Value B I have set the positionType="FixRelativeToTop". It can be seen in the property box but not in the source of the JRXML.
Is there any way to get rid of this white space ?
Thanks in advance.
I got this sorted by making single Value B row as another sub report. Remove all print when conditions from the sub report.
Added printWhenExpression and isRemoveLineWhenBlank attributes on the main report , sub report reportElement tag.
three position types are using in the jasper report for placed the element in the report. in the jasper report documentation,
positionType="Float" - The element floats in its parent section if it is pushed downward by other elements found above it. It tries to conserve the distance between it and the neighboring elements placed immediately above it
positionType="FixRelativeToTop" - The current report element simply ignores what happens to the other section elements and tries to conserve the y offset measured from the top of its parent report section. This is the default position.
positionType="FixRelativeToBottom" - If the height of the parent report section is affected by elements that stretch, the current element tries to conserve the original distance between its bottom margin and the bottom of the section.
try with following simple modification. for Value B, set "Position Type" property to "Float".
<reportElement positionType="Float" ... />
positionType property is the attribute of reportElement tag as given below,
<textField>
<reportElement positionType="Float" ... />
<textElement>
<font ... />
</textElement>
<textFieldExpression> ... </textFieldExpression>
</textField>
Related
In Jasper studio how can I disable/show background for a single page in the report.
I want to disable the watermark image which I set in the background for the last page.
The simplest method that I know when you need to compare current page towards totale number of pages is to use evaluation type "auto" on the element.
From EvaluationTimeEnum
Variables will be evaluated at a time corresponding to their reset type.
Solution adapted from lucianc's answer at https://community.jaspersoft.com/questions/514622/print-when-last-page
Create a variabile that contains current page having reset type Page (so it's evaluate when Auto as current page number)
<variable name="currentPageInAutoEval" class="java.lang.Integer" resetType="Page">
<variableExpression>$V{PAGE_NUMBER}</variableExpression>
</variable
set evaluation time to "Auto" on your element (textField, image etc) and in expression use ternary operator
In your case, no image on last page it would be
<image evaluationTime="Auto">
<imageExpression>$V{currentPageInAutoEval}.equals($V{PAGE_NUMBER}) ? null : yourImage</imageExpression>
</image>
Hence with evalutationTime="Auto" $V{currentPageInAutoEval} will be evaluated as resetType (Page) to current page number and $V{PAGE_NUMBER} as the total number of pages.
I am using iReports 4.7.1
I have 2 sub reports in my main report and they are in saperate bands. I need to hide the band if sub report returns no rows. I am able to get subreport value in my main report. But if i use that variable as a expression in the same band the value of that variable is becoming null, If i use that same variable in other details band, it is not becoming null.
I have two question to ask,
Why the value is becoming null if i use in same band?
Is their any other way to hide subreport returns no rows?
I followed this steps to create variable and return value from subreport to main report.
And also i tried this new Boolean($V{SUB_REPORT_ROW_CNT}.intValue()!=0) or $V{SUB_REPORT_ROW_CNT} != null expression in print when expression for the band.
Why the value is becoming null if i use in same band?
I need to see jrxml but probably you do not have correct EvaluationTime on the textField, try to set Band or Report example evaluationTime="Report" on the textField.
Is their any other way to hide subreport returns no rows?
The normal way to remove an empty subreport is by setting isRemoveLineWhenBlank="true" on the reportElement of the subreport.
Make sure your subreport return no page (empty) when no data by setting the whenNoDataType="NoPages" (or removing this attribute since this default) on the jasperReport tag
This will remove the subreport, note however if you like text under it to move you need to set positionType="Float", otherwise they will remain where they are since default is positionType="FixRelativeToTop"
I tried to create a report with Jaspersoft Studio following this tutorial.
And I have created a table like that:
But I don't know how to add a custom row to below this table like that.
Your report is made up of 3 areas.
1) Header Band(group header, page header, report header)
2) Detail Band
3) Footer Band(group footer, page footer, report footer)
If you want to add total area, you should add footer band and create variable for calculate total amount.
<variable name="TOTAL_AMOUNT" class="java.math.BigDecimal" resetType="Group" resetGroup="Your Group Name" calculation="Sum">
<variableExpression><![CDATA[$F{AMOUNT}]]></variableExpression>
</variable>
And put textField at footer band
<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{TOTAL_AMOUNT}]]></textFieldExpression>
Follow the link and Video, you will get your solution
1) http://bekwam.blogspot.in/2011/06/expanding-crosstab-in-jaspersoft.html
2) https://www.youtube.com/watch?v=unHbzWVvoRA
I'm using iReport v3.7.6 and JasperReports, I have a request to create a table where the first column acts to section/categorize the questions and answers displayed in the rest of the table. Example of requested output:
EDIT: For those of you not able to view the image, it is a 3-column table containing fields "Context", "Question", and "Answer". Each set of Question and Answer belongs to a single Context, which acts as a category for the set, and Context can act as a category for multiple sets of Question and Answer. The request is that it look something like this:
_________________________________
| Context1 | Question1 | Answer1 |
| |___________|_________|
| | Question2 | Answer2 |
| |___________|_________|
| | Question3 | Answer3 |
| |___________|_________|
| | Question4 | Answer4 |
|__________|___________|_________|
| Context2 | Question5 | Answer5 |
| |___________|_________|
| | Question6 | Answer6 |
|__________|___________|_________|
I know I can set iReport to not print repeated values, which solves part of my issue of not printing the Context on each line, but the second part of my problem is placing a cell border around the entire Context field so that it looks like the example above, that is, it looks like a dynamically expanding field that covers N number of rows. If I place a border around Context in the Details band of a report then I get the border for ever row in the table, resulting in a number of empty cells in the Context column. Is this kind of formatting possible using iReport 3.7.6? Would it be possible to group on the "Context" field and somehow place a border around the entire group?
Since the quantity of questions per Context category is known it would be possible to use flags in my dataset and conditionally style around the Context fields (e.g. flag set to "top" for first record in group and "last" for last record in group and style a frame's borders to show a top or bottom border according to flags), but that seems likes an awfully messy way of handling the issue. Plus, that bandage would break as soon as questions were dropped/added.
Another thought was creating a subreport that generated each Context individually, placing borders around the entire subreport, and combining the results in a master report's Detail band, but again that seems like a complex solution to an easy problem.
I can't see the image you provided due to my company's filter.
Are you pertaining to border around a grouped data? If yes, you can put a static text scoping the whole group header band, then only specify the border for top, left and right and send it to back of all the headers. It should be sent to back (Right click > Send to Back)
<staticText>
<reportElement positionType="Float" mode="Transparent" x="0" y="1" width="814" height="11" forecolor="#000000" backcolor="#F0F0F0"/>
<box>
<topPen lineWidth="0.75" lineColor="#CCCCCC"/>
<leftPen lineWidth="0.75" lineColor="#CCCCCC"/>
<rightPen lineWidth="0.75" lineColor="#CCCCCC"/>
</box>
<text><![CDATA[]]></text>
</staticText>
Then in the group's detail band, place another empty transparent static text that scopes the whole detail band, this time only specify the left and right borders.
In the group footer, place another empty transparent static text that scopes the whole group footer band and only specify the top border
How to display Full Text in Excel without truncation programatically?
Currently the data is getting truncated. Is it possible to automatically adjust the row height so as to display the enitre text?
I got these problems also and solved them this way:
For the first one, add the following property to your report:
net.sf.jasperreports.print.keep.full.text
and put it to true
You can also add this property to a specific text field. For more information, refer to this link
For the second one, as Deathtiny says, add isStretchWithOverflow=true to the field that you want, for it to grow with the amount of text in it.
I hope this helps.
Try to set the isStretchWithOverflow property to True for the concerned textfield :
<textField isStretchWithOverflow="true">
...
</textField>
It worked for me.