Null condition checking in report for float - jasper-reports

I am using iReport designer for designing report. Here data type of column data is real. In report corresponding data type is Float.
If the float value is empty or null i need to display that as a blank value.
The textField's attribute expression isBlankWhenNull="true" is not working for Float
Here is my code
<textField isBlankWhenNull="true">
<reportElement x="342" y="314" width="78" height="18"/>
<textElement/>
<textFieldExpression class="java.lang.Float"><![CDATA[$F{ws1}]]></textFieldExpression>
</textField>
I'm using iReport 3.7.6.
The result of my report is:
The cells with 0.0 should be blank.

Related

Text truncated on JasperReports

I have a JasperReports's report within an application that is truncating text and I am unsure how to get it to display the full name.
The code snippet below shows that I have included isStretchWithOverflow="true":
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="353" y="0" width="79" height="30"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{acname}]]></textFieldExpression>
</textField>
The JasperReports's image shows incorrect values. One of these should read: 'Double Time Pay - Bill Regular' and the other 'Double Time Pay - Bill Overtime'.

Comparing two columns on a row and removing if they match

I'm looking to create a report in iReport, this will display a row of Car weights which includes there expected weight and actual weight. I'm looking to only display the cars that have are different between the actual weight and expected weight. I'm also looking to display an extra columns on the right which displays how much they're different by.
E.g.
CAR Expected Weight ActualWeight WeightDIFF
-------------------------------------------
> NUGLN9L 2000kg 2200kg 200kg
> YBOL9GT 1700kg 1700kg 0kg (Shouldn't display this row)
> CL55GBP 1100kg 2200kg 1100kg
The part of jrxml:
<columnHeader>
<band height="61" splitType="Stretch">
<textField>
<reportElement x="108" y="0" width="100" height="20" uuid="205a44be-528a-4d6b-83e7-85cc0f417fd6"/>
<textFieldExpression><![CDATA[$F{car}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="219" y="0" width="100" height="20" uuid="704e546a-d4f1-4d8d-b5e7-a7ac8154d882"/>
<textFieldExpression><![CDATA[$F{expectedWeight}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="332" y="0" width="100" height="20" uuid="08846a54-7415-4f32-a0ef-41f2770e2278"/>
<textFieldExpression><![CDATA[$F{ActualWeight}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="443" y="0" width="100" height="20" uuid="7ebea114-3303-48c0-b877-f0940c62aa7f"/>
<textFieldExpression><![CDATA[$F{WeightDIFF}]]></textFieldExpression>
</textField>
</band>
</columnHeader>
Any help would be excellent
If you are using iReport designer you can select the field on screen, on the right pane of properties each field has a Print When Expression property. You can create a variable (Boolean is easiest). E.G
!$F{CarWeight1}.equals($F{CarWeight2})
Create a variable and set that as a boolean. Drop the variable into the print when expression property on each field. Also worth ticking remove line when blank for each field for formatting purposes.
Hope this helps.
As #AlexK pointed out, you can use the Print when expression.
After your <band> row, add the following (I assume $F{WeightDIFF} is an Integer):
<printWhenExpression><![CDATA[$F{WeightDIFF} > 0]]></printWhenExpression>

Print a field when certain value is not present Jasper reports

I am creating a JasperReports's report using iReport. I have a date field where once instance is 01-JAN-1900. I need any time the date field has this value then null value is printed. I have tried this:
<textField pattern="dd-MMM-yyyy" isBlankWhenNull="true">
<reportElement uuid="4dd05795-8363-4cf3-ad30-239aac3a086f" x="3" y="0" width="63" height="15">
<printWhenExpression><![CDATA[$F{TRAN_DATE} != "01-JAN-1900"]]></printWhenExpression>
</reportElement>
<textElement>
<font size="9"/>
</textElement>
<textFieldExpression><![CDATA[$F{TRAN_DATE}]]></textFieldExpression>
</textField>
But the value is still getting printed. How do I achieve this?
You cannot compare dissimilar types. Drop the String literal and compare datetime types.
If your field $F{TRAN_DATE} is in java.util.Date type, change it to java.lang.String and your condition should work.

Report's text field's "stretch with over flow" option add empty row in PDF export

I have set the "Stretch With Overflow" option True to some text fields , when the data over flow in the jasper viewer is working correctly, the text is on 2 rows but in PDF document the second row is empty: it just adds an empty row.
Exemple xml code :
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="165" y="0" width="35" height="10" isRemoveLineWhenBlank="true" uuid="a5d7ff35-a2dc-480e-80a7-9246d8618b27"/>
<textElement textAlignment="Left">
<font fontName="Futura Std Light" size="7"/>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[$F{montant} == null && $F{numeroAppelant} != null ? $F{numeroAppele}.toString():
$F{duree} != null ? $F{duree}.toString() :
$F{volumeKo} != null ? null : $F{montant}.toString()]]>
</textFieldExpression>
I found the solution,
I just set the line spacing property to 1.5 !
I found that when I change the font, it works wright. The problem that the same font on another report works fine with stretch with overflow option.

IReport: Detail band does not overflow to next page

I have two text fields inside a detail band. Here follows band XML code:
<band height="40" splitType="Prevent">
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="20" width="100" height="20" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" uuid="67cd0dfb-9a6d-4468- 8aac-3f48e539c584"/>
<textFieldExpression><![CDATA[$F{Resposta}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" isPrintRepeatedValues="false" x="0" y="0" width="100" height="20" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" uuid="c7fa90d3-2b11-4127-b319-5461a80acb2d"/>
<textFieldExpression><![CDATA[$F{Nome Questão}]]></textFieldExpression>
</textField>
</band>
As you can see, the text fields position type is "float", stretch type is "Relative to band height" print in first whole band is "true" print when detail overflows is "true" and stretch with overflow is also "true".
Band's Stretch Type is set to "Prevent".
I don't get it why it does not print all the rows I should get with my query. It should continue printing in more pages until all rows were displayed.
Any ideas?
First select your band details and set Stretch Type as "Stretch".
Secondly check and set following details by selecting your field :
Position type: float
Stretch type: relative to tallest object
Stretch with overflow: true (Checked)
Print repeated values: true (Checked)
Even if this not worked then add one more configuration -
Show out of bound content: true (Checked)
Note : If your field wrapped with frame then set frame properties also as above.
If you do above setting then I think there is no need to set detail overflows as "true".