I have created a report within the jrxml. I have specified to only print the details of each value if one of my fields is populated using the tag <printWhenExpression> with a value like so:
<textField>
<reportElement x="670" y="4" width="105" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
This works in filtering only relevant data, however it leaves me with a lot of blank rows within the report. I have enabled the condition isRemoveLineWhenBlank="true" to remove these blank rows from being displayed on my report. This has taken my report from 12 pages to 5, however, I still observe a large number of empty rows within the report.
Here is a ScreenShot of my reports design in ireport.
And here is a ScreenShot of the report run (I've blanked out my company's name from the classes)
The full report JRXML:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RIOBridgeReport" pageWidth="1530" pageHeight="842" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="10" rightMargin="5" topMargin="10" bottomMargin="10">
<property name="ireport.zoom" value="2.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.xls.exclude.origin.keep.first.band.1" value="columnHeader"/>
<parameter name="title" class="java.lang.String"/>
<parameter name="oneliner" class="java.lang.String"/>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[id[starts-with(.,'USCS')]]]></fieldDescription>
</field>
<field name="class" class="java.lang.String">
<fieldDescription><![CDATA[class]]></fieldDescription>
</field>
<field name="value" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg/value]]></fieldDescription>
</field>
<field name="value1" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg[1]/value]]></fieldDescription>
</field>
<field name="value2" class="java.lang.String">
<fieldDescription><![CDATA[constructor-arg[2]/value]]></fieldDescription>
</field>
<variable name="runDate" class="java.lang.String">
<initialValueExpression><![CDATA[new java.text.SimpleDateFormat("dd-MMM-yyyy HH:mm:ss Z").format(new java.util.Date())]]></initialValueExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="53" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="12" y="12" width="496" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{title} + " - " + $V{runDate}]]></textFieldExpression>
</textField>
<image>
<reportElement x="616" y="0" width="84" height="53"/>
<imageExpression><![CDATA["citi_corp_logo.gif"]]></imageExpression>
</image>
<textField isBlankWhenNull="true">
<reportElement x="12" y="32" width="496" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{oneliner}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement x="12" y="2" width="85" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Bean Name]]></text>
</staticText>
<staticText>
<reportElement x="228" y="2" width="85" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Class]]></text>
</staticText>
<staticText>
<reportElement x="428" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value]]></text>
</staticText>
<staticText>
<reportElement x="543" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value1]]></text>
</staticText>
<staticText>
<reportElement x="670" y="2" width="105" height="20"/>
<textElement>
<font fontName="Arial" size="10" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[Value2]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="24">
<textField isBlankWhenNull="true">
<reportElement x="12" y="2" width="216" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="228" y="2" width="185" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{class}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="428" y="2" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="543" y="4" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="670" y="4" width="105" height="20">
<printWhenExpression><![CDATA[$F{name}!= null]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA[$F{value2}]]></textFieldExpression>
</textField>
</band>
</detail>
<noData>
<band height="20">
<staticText>
<reportElement x="146" y="0" width="200" height="20"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="14" isBold="true"/>
</textElement>
<text><![CDATA[No data found]]></text>
</staticText>
</band>
</noData>
</jasperReport>
As you can see still a large amount of whitespace left within the report. Is there a way to completely remove them or push the blank rows to the end of the report.
Try placing everything inside a frame and add the "Remove line when blank" to the frame.
Instead of isRemoveLineWhenBlank for a field use the band properties of detail band. Therefore this condition should be put in the detail band properties printWhenExpression.
.
Related
I have a MAIN report and then a subreport that it is given the data from the MAIN report like this:
<subreport>
<reportElement x="0" y="0" width="555" height="224" uuid="b72a4572-ac0d-4a54-b57e-86e0420d1d94"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{sortedPositions})]]></dataSourceExpression>
<subreportExpression><![CDATA["/storage/intranet/balancing/templates/INVOICE_POSITIONS_PICASSO_TEMPLATE.jasper"]]></subreportExpression>
</subreport>
sortedPositions has the following fields
id
quantity
value
description
corridor
ProductConfiguration productConfiguration (another class)
When i try to group by any of the sortedPositions fileds the grouping doesn't work.
When i tried to book from the productConfiguration.field the grouping works!
The problem i that the field on which i want to group by is not in the productConfiguration and getting it directly from the sortedPositions doesn;t group as expected.
Here is the xml:
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="INVOICE_POSITIONS_PICASSO_TEMPLATE" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="2e9314a9-2d41-428a-91e9-63a890b65110">
<property name="ireport.zoom" value="1.6105100000000019"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="quantity" class="java.math.BigDecimal"/>
<field name="id" class="java.lang.Long"/>
<field name="value" class="java.math.BigDecimal"/>
<field name="corridor" class="java.lang.String">
<fieldDescription><![CDATA[productConfiguration.invoicePositionList.get(0).corridor]]></fieldDescription>
</field>
<field name="description" class="java.lang.String"/>
<field name="productName" class="java.lang.String">
<fieldDescription><![CDATA[productConfiguration.product.name]]></fieldDescription>
</field>
<field name="invoiceConfigurationId" class="java.lang.Long">
<fieldDescription><![CDATA[productConfiguration.invoiceConfiguration.id]]></fieldDescription>
</field>
<field name="productDescription" class="java.lang.String">
<fieldDescription><![CDATA[productConfiguration.description]]></fieldDescription>
</field>
<field name="productConfigId" class="java.lang.Long">
<fieldDescription><![CDATA[productConfiguration.id]]></fieldDescription>
</field>
<field name="period" class="java.sql.Timestamp">
<fieldDescription><![CDATA[invoice.period]]></fieldDescription>
</field>
<variable name="sumValueFinal" class="java.math.BigDecimal" resetType="Group" resetGroup="ProductGroup" calculation="Sum">
<variableExpression><![CDATA[$F{value}.abs()]]></variableExpression>
</variable>
<group name="ProductGroup">
<groupExpression><![CDATA[$F{corridor}]]></groupExpression>
<groupFooter>
<band height="58">
<staticText>
<reportElement mode="Opaque" x="0" y="37" width="455" height="20" backcolor="#CCCCCC" uuid="87ce8c73-7c58-4775-87e4-307521c9f0fe"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
<paragraph rightIndent="2"/>
</textElement>
<text><![CDATA[Subtotal:]]></text>
</staticText>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="460" y="37" width="95" height="20" backcolor="#CCCCCC" uuid="5456221b-3dee-46fc-a9a4-999da7067898"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$V{sumValueFinal}.abs()]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Opaque" x="0" y="8" width="45" height="20" backcolor="#FFFFFF" uuid="e3207aed-06dc-4e00-9eac-adab729b841b"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9" isBold="true"/>
<paragraph rightIndent="2"/>
</textElement>
<text><![CDATA[GROUP FINAL]]></text>
</staticText>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="45" y="8" width="102" height="20" backcolor="#99FF99" uuid="e26a9f2a-b3c1-44df-b088-29f42dfea069"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{productName}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="455" y="8" width="95" height="20" backcolor="#99FF99" uuid="e1f7c353-c700-4d8a-9aa8-1c17c2c94743"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{value}.abs()]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="265" y="8" width="95" height="20" backcolor="#99FF99" uuid="7c9b2c7f-22c9-492f-a103-8047690a0080"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{corridor}]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="360" y="8" width="95" height="20" backcolor="#99FF99" uuid="351f7355-61aa-4c38-a2e7-1250f965f2eb"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{quantity}.abs()]]></textFieldExpression>
</textField>
<textField pattern="#,##0.00" isBlankWhenNull="true">
<reportElement mode="Opaque" x="147" y="8" width="102" height="20" backcolor="#99FF99" uuid="3a2a9adb-2873-43e2-b8f5-48e3df353572"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
<paragraph rightIndent="2"/>
</textElement>
<textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
For reference the description -> NOT group correctly on the other hand the productDescription -> group correctly!
The issue was that the sortedPosition that i was "feeding" to the subreport wasn't properly and correctly sorted! Be careful the jasper group only makes one iteration through the data and the dataSource that you use for grouping should be sorted according what you want to group.
This question already has answers here:
iReport Import Background Image
(6 answers)
jasperreports: can see background image in pdf export but not in docx export
(3 answers)
Closed 2 years ago.
I have added Background Image by going to View -> Background Image
Below is my jrxml file
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Student_GradeCard" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1af80d91-9323-421a-9eaf-ed9c9f6e6975">
<property name="background.image.path" value="C:\path\BMSCELOGO.bmp"/>
<property name="background.image.widht" value="257"/>
<property name="background.image.height" value="193"/>
<property name="background.image.x" value="324"/>
<property name="background.image.y" value="182"/>
<queryString language="json">
<![CDATA[]]>
</queryString>
<field name="studentName" class="java.lang.String"/>
<field name="motherName" class="java.lang.String"/>
<field name="fatherName" class="java.lang.String"/>
<field name="USN" class="java.lang.String"/>
<field name="Semester" class="java.lang.String"/>
<field name="Session" class="java.lang.String"/>
<field name="SLNo" class="java.lang.Integer"/>
<field name="dateOfIssue" class="java.lang.String"/>
<field name="creditsRegistered" class="java.lang.Double"/>
<field name="creditsEarned" class="java.lang.Double"/>
<field name="SGPA" class="java.lang.Double"/>
<field name="cumulativeCreditsEarned" class="java.lang.Double"/>
<field name="CGPA" class="java.lang.Double"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="440" splitType="Stretch">
<frame>
<reportElement stretchType="ContainerHeight" x="0" y="0" width="800" height="396" uuid="a8145236-550e-4919-b555-04da6b0131c6">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box>
<pen lineWidth="2.0" lineStyle="Solid" lineColor="#FA8816"/>
</box>
<frame>
<reportElement stretchType="ContainerHeight" x="12" y="12" width="779" height="374" uuid="e584ab75-ec26-4776-a40b-24dd6cd3f84a"/>
<box>
<pen lineWidth="4.0" lineStyle="Solid" lineColor="#FA8816"/>
</box>
<staticText>
<reportElement x="132" y="12" width="388" height="30" forecolor="#0000AF" uuid="e84730b8-3fe1-4b36-acdf-82953272cb85"/>
<textElement textAlignment="Center">
<font fontName="Lucida Bright" size="20" isBold="true"/>
</textElement>
<text><![CDATA[B M S COLLEGE OF ENGINEERING,]]></text>
</staticText>
<staticText>
<reportElement x="502" y="12" width="198" height="30" forecolor="#0000AF" uuid="052e2686-4fd5-4818-b2b6-679cc9eec4b4"/>
<textElement verticalAlignment="Middle">
<font fontName="Lucida Bright" size="14" isBold="true"/>
</textElement>
<text><![CDATA[BANGALORE - 560 019]]></text>
</staticText>
<staticText>
<reportElement x="136" y="42" width="566" height="16" forecolor="#0C20E2" uuid="53cf89c0-758d-4914-a6bf-0db81aff79b8"/>
<textElement textAlignment="Center">
<font size="10"/>
</textElement>
<text><![CDATA[(Autonomous College under Visvesvaraya Technological University, Belgaum)]]></text>
</staticText>
<staticText>
<reportElement x="134" y="60" width="566" height="18" forecolor="#0C20E2" uuid="4bfe2a96-5be6-4ad7-94fc-09a81c7af9fb"/>
<textElement textAlignment="Center">
<font size="12" isBold="false"/>
</textElement>
<text><![CDATA[Karnataka, India]]></text>
</staticText>
<staticText>
<reportElement x="136" y="80" width="564" height="30" forecolor="#E77817" uuid="031f1e54-be88-441a-928d-5f839427d775"/>
<textElement textAlignment="Center">
<font fontName="Arial" size="18" isBold="true"/>
</textElement>
<text><![CDATA[GRADE CARD]]></text>
</staticText>
<staticText>
<reportElement x="139" y="102" width="562" height="30" forecolor="#FF0000" uuid="df1b9872-b463-4131-8fd1-15448bad61ac"/>
<textElement textAlignment="Center">
<font fontName="Times New Roman" size="17"/>
</textElement>
<text><![CDATA[Master of Technology]]></text>
</staticText>
<staticText>
<reportElement x="20" y="132" width="140" height="18" forecolor="#0C20E2" uuid="de0e642e-5342-425b-98ee-b92eb50cf702"/>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[Name of the Student:]]></text>
</staticText>
<staticText>
<reportElement x="20" y="152" width="140" height="18" forecolor="#0C20E2" uuid="b45c1157-90ab-4310-8f50-dedbde39d398"/>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[Name of the Mother:]]></text>
</staticText>
<staticText>
<reportElement x="20" y="172" width="140" height="18" forecolor="#0C20E2" uuid="bed17f85-0e82-4c23-b7e5-3dc0a5552cf3"/>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[Name of the Father :]]></text>
</staticText>
<staticText>
<reportElement x="20" y="192" width="140" height="18" forecolor="#0C20E2" uuid="a04692a4-a492-497e-ab24-43ac459f331a"/>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[University Seat Number :]]></text>
</staticText>
<textField>
<reportElement x="162" y="132" width="136" height="18" forecolor="#A52378" uuid="f506bd82-b67d-41da-a92b-faea3410004b"/>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{studentName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="162" y="152" width="138" height="18" forecolor="#A52378" uuid="5dade759-f45d-4d14-af66-4474cd81e61d">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{motherName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="162" y="172" width="136" height="18" forecolor="#A52378" uuid="d22e56ec-d2ed-4cc8-a030-9edcc5c28d32">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{fatherName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="162" y="192" width="136" height="18" forecolor="#A52378" uuid="a9894ed8-2970-4bc6-8a48-6418282c16a5"/>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{USN}]]></textFieldExpression>
</textField>
<image onErrorType="Blank">
<reportElement x="91" y="22" width="50" height="50" uuid="0acebf72-318c-4bce-86ec-8045378dae0e"/>
<imageExpression><![CDATA["C:\\path\\BMSCELOGO.bmp"]]></imageExpression>
</image>
<image onErrorType="Blank">
<reportElement x="704" y="27" width="37" height="50" uuid="55def125-f8c7-4e19-86dc-23b8b4c8bbaf"/>
<imageExpression><![CDATA["C:\\path\\VTULOGO.bmp"]]></imageExpression>
</image>
<image onErrorType="Blank">
<reportElement x="702" y="128" width="50" height="50" uuid="fd930389-8f40-4604-a32c-584c7b7b2614"/>
<imageExpression><![CDATA["C:\\path\\"+$F{USN}+".jpg"]]></imageExpression>
</image>
<staticText>
<reportElement x="480" y="154" width="68" height="18" forecolor="#0C20E2" uuid="f49e1d7b-00e6-4387-b76b-e6d04cb7b823"/>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[Semester:]]></text>
</staticText>
<staticText>
<reportElement x="480" y="172" width="68" height="18" forecolor="#0C20E2" uuid="354978b8-fa85-4e1b-831b-7b7a6d9b5faa">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Left">
<font fontName="Times New Roman" size="11" isBold="true"/>
</textElement>
<text><![CDATA[Session :]]></text>
</staticText>
<textField>
<reportElement x="550" y="172" width="136" height="18" forecolor="#A52378" uuid="a5f88a4a-7375-484c-bbcb-180bb516ac8b"/>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{Session}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="550" y="156" width="136" height="18" forecolor="#A52378" uuid="cecfb981-d018-419b-b661-f8936de3e6c1">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement>
<font fontName="Times New Roman" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{Semester}]]></textFieldExpression>
</textField>
</frame>
</frame>
</band>
</detail>
</jasperReport>
The Image added through Palette is getting displayed but background Image added through View -> Background Image is not working.
** I have also added code to the background band but still the image doesn't show in the preview nor in the pdf **
jrxml with background band
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Student-GradeCard" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="82747cb6-07de-4c80-8914-8c3873f497a7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<property name="background.image.path" value="C:\Users\Sony\Desktop\BMSCE_Templates\LOGOS USED IN GC(UG,PG)\VCH1.bmp"/>
<property name="background.image.widht" value="771"/>
<property name="background.image.height" value="531"/>
<property name="background.image.x" value="40"/>
<property name="background.image.y" value="40"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band height="555" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</band>
</background>
</jasperReport>
I need to generate a jasper document that is editable by the user after build using the Microsoft Word. The problem I encounter is that once I generate the document, I can not add new paragraphs between the existing ones using the ENTER key. What happens is that the text disappears behind the subsequent paragraphs, hiding under.
I tried using the overflow property and stretch with no results.
EDIT (clarification from a comment): GenericJon response is useful but, Could be this Microsoft Word property be setted when building the document with jasper exporter in order to open the document with this cell height property setted?
Thanks in advance!
My java application uses jasperreports-4.5.1.jar
I´m compiling my template with Jaspersoft iReport Designer 5.0.4
I use Microsoft Word 2013 to edit the document after build.
Here is the XML report :
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="SolicitudPresupuestoCM" pageWidth="595" pageHeight="842" columnWidth="475" leftMargin="60" rightMargin="60" topMargin="20" bottomMargin="20" whenResourceMissingType="Key" uuid="255a457f-fbfa-4352-8d45-fb04f539febb">
<property name="ireport.zoom" value="1.2396694214876032"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.scriptlethandling" value="0"/>
<property name="ireport.encoding" value="UTF-8"/>
<import value="net.sf.jasperreports.engine.*"/>
<import value="java.util.*"/>
<import value="net.sf.jasperreports.engine.data.*"/>
<parameter name="DIRECTORIO_IMAGENES" class="java.lang.String" isForPrompting="false"/>
<parameter name="fechaPropuesta" class="java.util.Date" isForPrompting="false"/>
<parameter name="numParrafosPrimerTexto" class="java.lang.Integer" isForPrompting="false"/>
<parameter name="nombreFirma" class="java.lang.String" isForPrompting="false"/>
<parameter name="cargoFirma" class="java.lang.String" isForPrompting="false"/>
<parameter name="expediente" class="java.lang.String" isForPrompting="false"/>
<parameter name="objeto" class="java.lang.String" isForPrompting="false"/>
<parameter name="aplicacionPresupuestaria" class="java.lang.String" isForPrompting="false"/>
<parameter name="importe" class="java.lang.String" isForPrompting="false"/>
<parameter name="empresa" class="java.lang.String" isForPrompting="false"/>
<parameter name="cif" class="java.lang.String" isForPrompting="false"/>
<parameter name="numFactura" class="java.lang.String" isForPrompting="false"/>
<queryString language="SQL">
<![CDATA[]]>
</queryString>
<field name="texto" class="java.lang.String"/>
<variable name="index" class="java.lang.Integer" incrementType="Report">
<variableExpression><![CDATA[Integer.valueOf($V{index}.intValue() + 1)]]></variableExpression>
<initialValueExpression><![CDATA[Integer.valueOf(0)]]></initialValueExpression>
</variable>
<pageHeader>
<band height="101" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="dfc390b7-4917-47da-970f-d9e69de9626d" x="355" y="79" width="121" height="14"/>
<textElement>
<font fontName="Arial" size="8" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{expediente}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
</columnHeader>
<detail>
<band height="23" splitType="Stretch">
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false">
<reportElement uuid="4fb4251a-765e-47b6-bd8d-60690d8df47a" x="0" y="0" width="475" height="10" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Justified">
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{texto}]]></textFieldExpression>
</textField>
</band>
<band height="73" splitType="Stretch">
<staticText>
<reportElement uuid="d0ec9d8d-de99-4b1f-a5f2-bd43b7ddd478" isPrintRepeatedValues="false" x="0" y="0" width="221" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[OBJECT: Payment of the invoice number]]></text>
</staticText>
<staticText>
<reportElement uuid="f8151046-97b5-452c-9423-50eea1b9f5d3" isPrintRepeatedValues="false" x="0" y="14" width="60" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[AMOUNT:]]></text>
</staticText>
<staticText>
<reportElement uuid="2fa9090a-0ecd-4084-8947-48bfc161bd16" isPrintRepeatedValues="false" x="0" y="28" width="73" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[APLICATION:]]></text>
</staticText>
<staticText>
<reportElement uuid="3abdff65-88a4-4201-af12-2d89c9e9b2cd" isPrintRepeatedValues="false" x="0" y="43" width="100" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[BIDDER:]]></text>
</staticText>
<staticText>
<reportElement uuid="eecdd67b-eb52-47e3-ae9e-fd5be9f0578e" isPrintRepeatedValues="false" x="335" y="43" width="47" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[NIF/CIF:]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="45e2af4d-aa76-4d8a-b736-09b9298b24c1" isPrintRepeatedValues="false" x="60" y="14" width="415" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{importe}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="0a69cee5-7970-4972-9b74-ebc4fe6687d5" isPrintRepeatedValues="false" x="77" y="28" width="306" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{aplicacionPresupuestaria}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="ea832f4b-30cd-4240-84dd-c39a01674540" isPrintRepeatedValues="false" x="100" y="43" width="235" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="291d18a5-4e09-41af-81ef-38da536f868b" isPrintRepeatedValues="false" x="383" y="43" width="92" height="15" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{cif}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement uuid="15cc14e4-06ec-4c5f-92ff-5f7261bc83f8" isPrintRepeatedValues="false" x="221" y="0" width="58" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{numFactura}]]></textFieldExpression>
</textField>
<staticText>
<reportElement uuid="9e5ab1d9-008f-44c5-b25a-c95184f1ff1b" isPrintRepeatedValues="false" x="279" y="0" width="86" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[realtive to]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="7c57f57d-033d-4e85-8f18-d2f40521e5b3" isPrintRepeatedValues="false" x="365" y="0" width="110" height="14" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{objeto}]]></textFieldExpression>
</textField>
</band>
<band height="85" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="386f28db-aa1e-46e8-8c31-dd01a5c041c8" x="0" y="20" width="475" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{cargoFirma}]]></textFieldExpression>
</textField>
<staticText>
<reportElement uuid="d4e52606-aaf0-48a8-8dd3-b1532b0f5eed" key="staticText" isPrintRepeatedValues="false" x="0" y="0" width="135" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Somewhere,]]></text>
</staticText>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement uuid="a8ceb09b-bc70-4875-90de-877cf9889351" isPrintRepeatedValues="false" x="0" y="65" width="475" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{nombreFirma}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy" isBlankWhenNull="false">
<reportElement uuid="71a758b9-a5bc-4890-ae2f-74263245d0c4" isPrintRepeatedValues="false" x="135" y="0" width="220" height="20" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
</reportElement>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{fechaPropuesta}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="122">
<staticText>
<reportElement uuid="47118a66-c23c-4b35-b90f-7e469eb97a99" key="staticText" x="0" y="0" width="73" height="20"/>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Otherwhere,]]></text>
</staticText>
<staticText>
<reportElement uuid="880fd5a8-8a35-49d2-b226-5413d7d02120" key="staticText" x="0" y="20" width="475" height="20"/>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[The director of ...]]></text>
</staticText>
<staticText>
<reportElement uuid="6a5f6b70-0574-4c6f-8e44-09356eda2a51" key="staticText" x="0" y="71" width="475" height="20"/>
<textElement>
<font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
</textElement>
<text><![CDATA[Charles Irwin]]></text>
</staticText>
</band>
</pageFooter>
</jasperReport>
Here is the result document that I should easily customize after build.
Go to download document
The row will re-size when you write to it, when you add the net.sf.jasperreports.export.docx.flexible.row.height property to the report with the true value.
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ...>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.docx.flexible.row.height" value="true"/>
More Info about property:
Link
NOTE: you should think on paradigm, that reports are "read only". So users should fill data into some programmatic form and afterwards the reports is generated ...
JasperReports achieves the layout of the document by using a table. In MS Word, you should be able to see this by selecting Table Tools > Layout > Show Gridlines. All of the rows have a specific fixed height, so when you add more content beyond the size of a cell, it will not be visible.
To enable the cells to grow as you add new paragraphs, right-click inside the cell you want to add content to, and select Table Properties.... On the Row tab, un-check the box next to Specify Height. The row height should then increase to accommodate the contents.
I have the below report, developed using iReport 3.0 (we have to use this version because of system constraints). But no matter what I do, I can not get rid of the white space between the Page Header (addresses) and the Column Header.
JRXML:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="customisation_summary" pageWidth="595" pageHeight="700" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isFloatColumnFooter="true">
<style name="alternateStyle" isDefault="false" backcolor="#FFFFFF" fontName="Arial">
<conditionalStyle>
<conditionExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)]]></conditionExpression>
<style isDefault="false" style="alternateStyle" backcolor="#F7F7F7"/>
</conditionalStyle>
</style>
<parameter name="orderId" class="java.lang.String">
<defaultValueExpression><![CDATA[new Integer(0).toString()]]></defaultValueExpression>
</parameter>
<parameter name="REPORT_IMG_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\kukri\\workspaces\\sts_3_0_0\\clubshop\\clubshop\\src\\main\\webapp\\jasper\\images\\"]]></defaultValueExpression>
</parameter>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\kukri\\workspaces\\sts_3_0_0\\clubshop\\clubshop\\src\\main\\webapp\\jasper\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT so.customer_id, so.order_date, so.order_ref, p.product_code, p.colour_code, p.name, SUM(soi.quantity) AS quantity, sz.size, '-' AS uom, '-' AS location, scc.unit_charge, SUM(soi.quantity * scc.unit_charge) total_charge
FROM sales_order AS so, sales_order_item AS soi, product AS p, stock AS st, size AS sz, stock_currency_charge AS scc
WHERE so.id = soi.order_id
AND soi.stock_id = st.id
AND st.product_id = p.id
AND st.id = scc.stock_id
AND st.size_id = sz.id
AND so.currency = scc.currency_code
AND so.id = '$P!{orderId}'
GROUP BY st.id
ORDER BY p.name, sz.display_seq]]>
</queryString>
<field name="customer_id" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="order_date" class="java.sql.Timestamp">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="order_ref" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="product_code" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="colour_code" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="quantity" class="java.lang.Integer">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="size" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="uom" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="location" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="unit_charge" class="java.math.BigDecimal">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="total_charge" class="java.math.BigDecimal">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<title>
<band height="72" isSplitAllowed="false">
<image onErrorType="Icon">
<reportElement key="image-4" x="-1" y="0" width="555" height="71"/>
<imageExpression class="java.lang.String"><![CDATA[$P{REPORT_IMG_DIR} + "//Top_Image.png"]]></imageExpression>
</image>
<staticText>
<reportElement x="307" y="51" width="247" height="20"/>
<textElement textAlignment="Right">
<font size="14"/>
</textElement>
<text><![CDATA[Order Customisation Pick Sheet]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="45">
<staticText>
<reportElement x="399" y="2" width="62" height="18"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Order Ref: ]]></text>
</staticText>
<textField>
<reportElement x="464" y="20" width="92" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression class="java.util.Date"><![CDATA[$F{order_date}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="464" y="1" width="93" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{order_ref}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="399" y="20" width="62" height="20"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[Order Date: ]]></text>
</staticText>
<subreport>
<reportElement x="179" y="1" width="175" height="40"/>
<subreportParameter name="customer_id">
<subreportParameterExpression><![CDATA[$F{customer_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "customisation_jobsheet_summary_invaddy.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="0" y="0" width="175" height="40"/>
<subreportParameter name="customer_id">
<subreportParameterExpression><![CDATA[$F{customer_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "customisation_jobsheet_summary_del_addy.jasper"]]></subreportExpression>
</subreport>
</band>
</pageHeader>
<columnHeader>
<band height="20">
<staticText>
<reportElement mode="Opaque" x="23" y="1" width="79" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Product Code]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="463" y="1" width="39" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[UOM]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="178" y="1" width="231" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Product ]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="102" y="1" width="76" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Colour]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="409" y="1" width="26" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Size]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="435" y="1" width="28" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[QTY]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="501" y="1" width="55" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Location]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="2" y="1" width="21" height="18" backcolor="#CCCCCC"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[#]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="19">
<textField>
<reportElement style="alternateStyle" isPrintRepeatedValues="false" x="21" y="1" width="79" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{product_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" isPrintRepeatedValues="false" x="176" y="1" width="231" height="18"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" isPrintRepeatedValues="false" x="100" y="1" width="76" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{colour_code}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" x="433" y="1" width="28" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{quantity}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" x="461" y="1" width="39" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{uom}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" x="499" y="1" width="55" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{location}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="1" width="21" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="alternateStyle" x="407" y="1" width="26" height="18"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{size}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="50"/>
</columnFooter>
<summary>
<band height="80"/>
</summary>
</jasperReport>
I have a simple report. It has two bands title and detail.
In the Title I have a static text, in the Detail I have one textField.
The textField is set to stretchwithoverflow = "true". If I set the height for this field to fit one raw information, I get for the larger information one and a half rows. So one textField, in the textField I have 2 rows information, first row displayed correctly, second one - I can see a half height.
Can this be done? Expand only the rows that contain larger information and the larger information will fit well in the text field?
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report7" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="15f9d2dd-21ce-41ec-bcb8-c1aca3a77e37">
<parameter name="EndDate" class="java.util.Date">
<defaultValueExpression><![CDATA[new java.util.Date()]]></defaultValueExpression>
</parameter>
<parameter name="Project" class="java.util.Collection"/>
<parameter name="Severity" class="java.util.Collection"/>
<parameter name="StartDate" class="java.util.Date">
<defaultValueExpression><![CDATA[new java.util.Date(112, 0, 01)]]></defaultValueExpression>
</parameter>
<parameter name="Project_Sets" class="java.util.Collection"/>
<queryString>
<![CDATA[some query]]>
</queryString>
<field name="crid" class="java.lang.String"/>
<field name="SEVER" class="java.lang.String"/>
<field name="product" class="java.lang.String"/>
<field name="state" class="java.lang.String"/>
<field name="status" class="java.lang.String"/>
<field name="submit_date" class="java.lang.String"/>
<field name="aging" class="java.lang.Long"/>
<title>
<band height="25" splitType="Stretch">
<staticText>
<reportElement uuid="63eef93a-7e8f-4c69-b9d6-4447fe90673d" x="0" y="0" width="555" height="25" forecolor="#3399FF"/>
<textElement textAlignment="Center">
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Defects Aging]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="32">
<rectangle>
<reportElement uuid="9a2288d4-87ce-4ee7-b04e-267a7ee0ea8b" x="0" y="0" width="555" height="32" backcolor="#99CC00"/>
</rectangle>
<staticText>
<reportElement uuid="9281aa7a-4bcc-4456-9f25-83c7b2360a01" x="0" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[CRID]]></text>
</staticText>
<staticText>
<reportElement uuid="cacda134-069c-43ae-abc1-76f5c865df41" x="79" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Severity]]></text>
</staticText>
<staticText>
<reportElement uuid="d798786f-5ee0-4e76-8a35-2f908af6e92c" positionType="Float" x="158" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Product]]></text>
</staticText>
<staticText>
<reportElement uuid="6be4792d-01a5-4d18-940d-90f40417c7ad" positionType="Float" x="237" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[State]]></text>
</staticText>
<staticText>
<reportElement uuid="fa447ca9-121c-43fb-a7bf-1b29ada93adf" positionType="Float" x="316" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Status]]></text>
</staticText>
<staticText>
<reportElement uuid="b2d8f1db-871b-4e34-942f-b8c4a87a358b" positionType="Float" x="395" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Submit Date]]></text>
</staticText>
<staticText>
<reportElement uuid="c3eddc7c-25ca-4e29-a01e-13e856b67d03" x="474" y="0" width="79" height="32" forecolor="#FFFFFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true"/>
</textElement>
<text><![CDATA[Days]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="81" splitType="Stretch">
<elementGroup>
<textField isStretchWithOverflow="true">
<reportElement uuid="6422c6d3-40b9-4e38-8bb4-ded91c91ac17" stretchType="RelativeToBandHeight" x="158" y="0" width="79" height="39"/>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{product}]]></textFieldExpression>
</textField>
</elementGroup>
</band>
</detail>
</jasperReport>
In the same band if there are more items and you want to have all same stretched. It has to be set to all of them to stretchType="RelativeToTallestObject" and isStretchWithOverflow="true".
<textField isStretchWithOverflow="true" pattern="###0">
<reportElement stretchType="RelativeToTallestObject" x="1576" y="0" width="91" height="20"/>
<textElement textAlignment="Center"/>
<textFieldExpression class="java.lang.Long"><![CDATA[$F{count_tohfa}]]></textFieldExpression>
</textField>
Report property: Add this
net.sf.jasperreports.text.save.line = true
net.sf.jasperreports.export.html.wrap.break.word = true
Source: Word Wrapping HTML versus PDF