How to Hide lines after isPrintRepeatedValues="false" in Jasper reports - jasper-reports

I have requirement to hide the line after setting a property isPrintRepeatedValues="false" and values is not repeated but the getting line.and check the below image and highlighted with red color arrow.
That is shouldn't come and USA will come central. Can i achive this requirement if possible?

You can use subreport for all fields exclude first field.
First field and subreport placed into frame with borders.
For first field set properties:
stretchType="RelativeToBandHeight"
verticalAlignment="Middle"
First field haven't borders.

Related

How to stretch fields horizontally in jasperreport? [duplicate]

This question already has answers here:
Dynamic column cell width
(3 answers)
How to stretch a text field relative to data width in Jasper Reports
(3 answers)
How to Stretch Jasper Table Columns based on Content
(1 answer)
How to increase the column width dynamically in iReport using dynamic report?
(2 answers)
Closed 3 years ago.
I'm using JasperReports with Eclipse Plugin in a Java project.
In JasperReports I'd like to stretch a field horizontally and move the next element to the right if the text field is too long.
Even if I set all the elements with position float nothing happens.
If I set the text field with isStretchWithOverflow="true" I get vertical stretch, like this.
What I'm looking for is something like this:
1 X 11111 Campo di Testo
1 X 12345678901234567890123456789012345678901234567890 Campo di Testo
As Amongalen says in their answer there is no property to stretch horizontally.
but,
you can concatenate multiple fields in same text field to achieve your desired result.
${field1} + " " + ${field2}
full jrxml for textField
<textField>
<reportElement x="0" y="0" width="100" height="30" uuid="6757386c-10c7-451f-bb1a-97951697d782"/>
<textFieldExpression><![CDATA[${field1} + " " + ${field2}]]></textFieldExpression>
</textField>
As far as I know it is not possible to stretch fields horizontally.
As you can see, isStretchWithOverflow causes the field to stretch vertically only.
The other option you mention, float position refers to... well... position. If one of the field on top stretches vertically or disappears, then all field below it, with position set to float will be moved up or down accordingly.
I've tried to achieve this myself for a long time but eventually gave up, as it is most likely not possible.
In some cases, an acceptable solution would be to place multiple field with different sizes on each other. Then, based on the texts length, you show only one of them.

Jasper Reports 5: Title Band, how to create a footer?

i have a title band. my report is landscape 595 by 842. i simply want the title band to take up a full page and be able to add text to the very bottom of that title page/band.
i have tried position fix relative to bottom. it still floats up. i have tried making the title band 559 high (with 36 top margin to make 595). that works except there is tons of white space and so if something on the title expands (dynamic data) the text at title page bottom breaks to second page.
Got it! Problem is that title band does not stretch, so fix relative to bottom does not work. Solution is to add a background band, height of report (minus margin). Then put page footer there, is will show on title and all other pages. Then add a blank page footer to save white space for the real footer in the background. done.
Why not use only the pageFooter and then if you only like it to display on first page use the printWhenExpression.
<pageFooter>
<band height="50">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue()==1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="dd4c229b-7453-4026-b01e-cfc325053335"/>
<textFieldExpression><![CDATA["You will only see me on first page"]]></textFieldExpression>
</textField>
</band>
</pageFooter>
Note the pageFooter will be present on every page (even if blank), this is the famous firstPageFooter request / tracker, but this seems not to be your case since you are already adding it later...

Take sensitive frame with height of detail row

I try to border my bands in this way:
But I have a text field of my row detail with property isStretchWithOverflow="true"
In this way when I try to print my report, on the rows with overflowed text field, I've a discontinue on my border (white space instead draw line of frame).
Very simple.
I've added this property stretchType="RelativeToTallestObject" on my frame object.
So the line has not discontinuity.

JasperReports text field stretching - can stretch height be limited?

I've got the following problem with a JasperReports subreport that I've been trying to solve for the past couple of days with no success. Below is an image of what I'm trying to do.
I've got a subreport in one of my reports that is relatively simple. Its got a title band with a single text field (marked brown in the image) for the subreport title and a detail band with two items: a subreport (marked blue in the image) printing my line items and a text field (marked red in the image) printing the comments associated with the line items printed to the left of it. The line item subreport can print a variable number of line items (datasource backed by a bean collection). My customers requirement is that the comments field stretches and shows the text entered, but be limited by the height of the line item section (represented by the arrows on the image). I somehow need to prevent the comments from stretching beyond the line items and make them of equal height (there should be no green box in the image).
Does anyone have any tips how this could be (and can it at all be) achieved in JasperReports?
p.s.
We are currently compiling our reports with JR version 3.6
Put both the subreport and the text field into a frame. For the text field, set "Stretch with overflow" to false and "Stretch type" to "Relative to tallest object"
The text field will stretch relative to the tallest object in it's container. It's container is now the frame, so the "tallest object" can only be the subreport. Make sure the elements are the same height when you define them, otherwise they will grow at different rates.
JRXML sample:
<band height="50">
<frame>
<reportElement x="0" y="0" width="555" height="50"/>
<subreport>
<reportElement x="0" y="0" width="378" height="50"/>
...
</subreport>
<textField isStretchWithOverflow="false">
<reportElement stretchType="RelativeToTallestObject" x="378" y="0" width="177" height="50"/>
...
</textField>
</frame>
</band>

How to change the background color of JasperReports chart

The default background color of JasperReports chart is sky blue.
I want to change that background color.
How to change it?
If you are using iReport select the charts properties and change the background property to the colour you desire.
If not in the XML for the chart there should be an xml tag called <itemLabel>.
Within this you can set the foreground and the background of the chart as seen bellow.
<itemLabel color="#000000" backgroundColor="#FFFFFF"/>
I had this problem. Contrary to even some of the official documentation, the itemLabel tag has no effect on the chart appearance.
Instead, to set the background colour of the entire chart area, create or change the backcolor attribute in the reportElement tag for your chart. E.g:
<barChart>
<chart>
<reportElement mode="Opaque" backcolor="#CCCCCC" x="0" y="0" width="400" height="400"/>
...
Note that the mode attribute must be set to "Opaque" for the colour to be rendered.
If you are using iReport, you can of course change the colour by using the properties tab.
If you want to set the background colour for only the actual chart (area within the axes where the data is displayed), set the backcolor attribute within the plot element of your chart. E.g:
<barChart>
...
<barPlot>
<plot backcolor="#CCCCCC"/>
...
This does not feature on the properties tab, so you will need to edit the xml directly.