I am getting error when using sub report in jasper report.
First there was an error of resource not found: subreport.jrxml
Then the second error was subreport was not showing in the master report.
Now there is a new error and i am unable to sort it out.
This is the stack trace of my error.
"C:\Program Files\Java\jdk1.8.0_231\bin\java.exe"
"-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2019.2.3\lib\idea_rt.jar=38754:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program
Files\Java\jdk1.8.0_231\jre\lib\charsets.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\deploy.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\access-bridge-64.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\cldrdata.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\dnsns.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\jaccess.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\jfxrt.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\localedata.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\nashorn.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunec.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunjce_provider.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunmscapi.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\sunpkcs11.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\ext\zipfs.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\javaws.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jce.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jfr.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jfxswt.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\jsse.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\management-agent.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\plugin.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\resources.jar;C:\Program
Files\Java\jdk1.8.0_231\jre\lib\rt.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\out\production\Medicare;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\fontawesomefx-8.9.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\mysql-connector.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-beanutils-1.8.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-collections-3.2.1-1.0.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-digester-2.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-logging-1.1.1-1.0.0.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\commons-logging-1.1.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\groovy-all-2.0.1.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined
Libs\itext-2.1.7.js2.jar;C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\lib\Refined Libs\jasperreports-5.6.0.jar" model.Main Exception
in thread "JavaFX Application Thread" java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException at
javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774) at
javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Node.fireEvent(Node.java:8411) at
javafx.scene.control.Button.fire(Button.java:185) at
com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at
com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at
com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at
com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at
com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at
com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54) at
javafx.event.Event.fireEvent(Event.java:198) at
javafx.scene.Scene$MouseHandler.process(Scene.java:3757) at
javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485) at
javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762) at
javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494) at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method) at
com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:432)
at
com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:410)
at
com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555) at
com.sun.glass.ui.View.notifyMouse(View.java:937) at
com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at
com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.lang.reflect.InvocationTargetException at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71) at
sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275) at
javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771) ...
48 more Caused by: net.sf.jasperreports.engine.JRException: Errors
were encountered when compiling report expressions class file:
C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:246: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:364: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ C:\wamp64\www\GitKraken\distribution\experts-machines\JavaFX\Younas
Traders\Invoice_1582493155805_798440.java:482: error: ';' expected
value = ((java.util.ArrayList)parameter_listOfItems.getValue())];
//$JR_EXPR_ID=19$
^ 3 errors
at
net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:204)
at
net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:354)
at
net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:340)
at
net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:605)
at
controller.ViewPendingOrders.generateInvoice(ViewPendingOrders.java:123)
... 58 more
Master Jasper Report.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<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" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4eedbb89-b4f6-4469-9ab6-f642a1688cf7">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Title" forecolor="#FFFFFF" fontName="Times New Roman" fontSize="50" isBold="false" pdfFontName="Times-Bold"/>
<style name="SubTitle" forecolor="#CCCCCC" fontName="Times New Roman" fontSize="18" isBold="false" pdfFontName="Times-Roman"/>
<style name="Column header" forecolor="#666666" fontName="Times New Roman" fontSize="14" isBold="true"/>
<style name="Detail" mode="Transparent" fontName="Times New Roman"/>
<style name="Row" mode="Transparent" fontName="Times New Roman" pdfFontName="Times-Roman">
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style mode="Opaque" backcolor="#EEEFF0"/>
</conditionalStyle>
</style>
<style name="Table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
<topPen lineWidth="1.0" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="Table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#CACED0">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
<conditionalStyle>
<conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
<style backcolor="#D8D8D8"/>
</conditionalStyle>
</style>
<subDataset name="tableDataset" uuid="f13e6d36-5148-4ecc-bbe3-3035def80980">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<parameter name="TestParameter" class="java.lang.String"/>
<parameter name="listOfItems" class="java.util.ArrayList"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="orderId" class="java.lang.String"/>
<field name="dealerId" class="java.lang.String"/>
<field name="dealerName" class="java.lang.String"/>
<field name="dealerAddress" class="java.lang.String"/>
<field name="dealerContact" class="java.lang.String"/>
<field name="orgPrice" class="java.lang.String"/>
<field name="bonus" class="java.lang.String"/>
<field name="discount" class="java.lang.String"/>
<field name="finalPrice" class="java.lang.String"/>
<field name="listOfItems" class="java.util.ArrayList"/>
<detail>
<band height="503">
<staticText>
<reportElement x="1" y="240" width="100" height="20" uuid="023f299c-597f-46e6-b9bb-8330926484e4"/>
<text><![CDATA[Bonus]]></text>
</staticText>
<textField>
<reportElement x="1" y="264" width="362" height="46" uuid="c75b5fd2-6c4b-480b-91a3-9440ca3c71fa"/>
<textFieldExpression><![CDATA[$F{bonus}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="380" y="244" width="84" height="16" uuid="2560e5b8-b3f2-4962-9e4a-7890ee48eb84"/>
<text><![CDATA[Invoice Payment]]></text>
</staticText>
<staticText>
<reportElement x="380" y="264" width="84" height="16" uuid="c7d9167e-2c29-41af-9a2b-d576f5d5cf33"/>
<text><![CDATA[Discount]]></text>
</staticText>
<staticText>
<reportElement x="380" y="284" width="84" height="16" uuid="3ed37e4e-be08-4dd8-a751-0b788a4ebc54"/>
<text><![CDATA[Payable Payments]]></text>
</staticText>
<textField>
<reportElement x="465" y="282" width="90" height="18" uuid="6ef42f61-bd40-4db6-82e2-793c47f72ccc"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{finalPrice}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="465" y="264" width="90" height="16" uuid="62dbd5d9-18ee-49c8-a868-740087d110b1"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{discount}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="465" y="244" width="90" height="16" uuid="453a26cb-3638-4bf7-9222-643d10f48207"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{orgPrice}]]></textFieldExpression>
</textField>
<line>
<reportElement x="1" y="233" width="555" height="1" uuid="44809847-2137-43f5-aef1-e7f4e8c76491"/>
</line>
<staticText>
<reportElement positionType="Float" x="0" y="339" width="261" height="101" uuid="1a0d7088-5af7-4865-8be1-41ec5f51fb36"/>
<box>
<topPen lineWidth="1.1" lineStyle="Dashed"/>
<leftPen lineWidth="1.1" lineStyle="Dashed"/>
<bottomPen lineWidth="1.1" lineStyle="Dashed"/>
<rightPen lineWidth="1.1" lineStyle="Dashed"/>
</box>
<text><![CDATA[Your notes here
Your notes here
Your notes here
Your notes here
Your notes here]]></text>
</staticText>
<staticText>
<reportElement x="0" y="5" width="210" height="25" uuid="e622555d-198b-4ccd-a4a1-c59c53304058">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="19" isBold="true"/>
</textElement>
<text><![CDATA[Younas Traders]]></text>
</staticText>
<staticText>
<reportElement x="0" y="30" width="205" height="15" uuid="c226e44d-3bb5-4145-b0b3-903bf1d79fde"/>
<text><![CDATA[Street address]]></text>
</staticText>
<staticText>
<reportElement x="0" y="45" width="205" height="15" uuid="b96f7183-44f8-43ad-ba60-43d8fbf50b6e"/>
<text><![CDATA[City, street, ZIP code]]></text>
</staticText>
<staticText>
<reportElement x="0" y="60" width="205" height="15" uuid="b8cc42fd-b569-497d-834d-7e854040ad18"/>
<text><![CDATA[Phone number, web address, ecc.]]></text>
</staticText>
<staticText>
<reportElement x="0" y="90" width="84" height="25" uuid="57aed2b1-4f4e-40a3-a6ad-54dae8dd4c5a">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Bill to]]></text>
</staticText>
<staticText>
<reportElement x="0" y="115" width="40" height="15" uuid="33274f5d-5b7e-4be2-a2ff-65d452a618ed"/>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement x="0" y="130" width="40" height="15" uuid="1d3045ed-03d6-4253-a959-aeeb491b73ca"/>
<text><![CDATA[Name]]></text>
</staticText>
<textField>
<reportElement x="40" y="115" width="140" height="15" uuid="424a926c-30f5-48ba-965e-e9c64ea93c09"/>
<textFieldExpression><![CDATA[$F{dealerId}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="40" y="130" width="140" height="15" uuid="b3fd9ce4-cab2-4102-882a-1f51e38fef4e"/>
<textFieldExpression><![CDATA[$F{dealerName}]]></textFieldExpression>
</textField>
<textField pattern="EEEEE dd MMMMM yyyy">
<reportElement x="465" y="10" width="84" height="20" uuid="bb10dbe1-0a4f-4722-9953-c163b63cf979"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="415" y="10" width="50" height="20" uuid="0f86baff-6386-4f3f-b3fe-2388707babe8"/>
<box rightPadding="4"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Date:]]></text>
</staticText>
<staticText>
<reportElement x="415" y="30" width="50" height="20" uuid="0b3f9342-da78-4cfa-9fc5-2301c4749678"/>
<box rightPadding="4"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Invoice #]]></text>
</staticText>
<textField>
<reportElement x="465" y="30" width="84" height="20" uuid="c108d3cf-4809-4862-abca-6ed67e9f6066"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{orderId}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="360" y="115" width="50" height="15" uuid="235bf8b6-1e1e-49c7-b59f-7a46c30b8209"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Address]]></text>
</staticText>
<staticText>
<reportElement x="360" y="90" width="196" height="25" uuid="139ebe8d-25b0-411e-986c-270015400874">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Contact Info]]></text>
</staticText>
<textField>
<reportElement x="410" y="115" width="146" height="15" uuid="92657a77-3115-4437-9c5c-79cd3a7b8de7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{dealerAddress}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="410" y="131" width="146" height="14" uuid="70bf5644-2451-4079-ad60-00d7462e5029"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{dealerContact}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="360" y="130" width="50" height="15" uuid="665f25c2-8663-4951-b699-1ab863bdeb76"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Contact]]></text>
</staticText>
<line>
<reportElement x="-10" y="84" width="556" height="1" uuid="806ce5df-1219-4876-ae0c-ca7405b1f246">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
<break>
<reportElement x="0" y="480" width="556" height="1" uuid="210638e1-1901-4517-bef1-aad33e0bf0d2"/>
</break>
<subreport>
<reportElement x="3" y="180" width="552" height="40" uuid="e328f355-34f5-4f03-b487-f3976e3363f0"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfItems})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{listOfItems}]]]></subreportExpression>
</subreport>
</band>
</detail>
<lastPageFooter>
<band height="71"/>
</lastPageFooter>
</jasperReport>
Sub Report
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.11.0.final using JasperReports Library version 6.11.0-0c4056ccaa4d25a5a8c45672d2f764ea3498bebb -->
<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="ItemsDetail" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="017e107d-3aa8-4a1e-8830-154cd4e30b51">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="itemNo" class="java.lang.String"/>
<field name="itemName" class="java.lang.String"/>
<field name="quantity" class="java.lang.String"/>
<field name="unit" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="36" splitType="Stretch">
<staticText>
<reportElement x="0" y="10" width="40" height="26" uuid="a41d735b-427a-407f-ab30-823815930dbc">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="f0337735-db21-4453-bf38-5b2818b709bd"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Sr No.]]></text>
</staticText>
<staticText>
<reportElement x="40" y="10" width="80" height="26" uuid="2932eb5f-61e2-4ec9-a398-06110d34db6f">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="25158f69-d1fc-4a93-a0c0-a631797fcf41"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Item No]]></text>
</staticText>
<staticText>
<reportElement x="120" y="10" width="270" height="26" uuid="07ca2115-2395-4a57-b1b0-49bce35d7ae9">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1b19a0c1-1fe2-4816-a6f4-d6537129a33d"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Item Name]]></text>
</staticText>
<staticText>
<reportElement x="390" y="10" width="80" height="26" uuid="ae2b917d-3dd1-4543-89d6-617847e668c6">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="93a5ea62-c6bc-4420-8220-beb00fa064c8"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Quantity]]></text>
</staticText>
<staticText>
<reportElement x="470" y="10" width="85" height="26" uuid="48e2794a-6a19-4012-b023-31366dc43306">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="dde337f4-f033-42bb-8533-654ccdea99d0"/>
</reportElement>
<box>
<pen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12"/>
</textElement>
<text><![CDATA[Unit]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="40" splitType="Stretch">
<textField>
<reportElement x="40" y="0" width="80" height="20" uuid="21fd205d-e27c-41db-89d3-bc2e34001baf">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="25158f69-d1fc-4a93-a0c0-a631797fcf41"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{itemNo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="0" width="270" height="20" uuid="c389cf68-9eb4-4de4-a38a-2d0a184267a7">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="1b19a0c1-1fe2-4816-a6f4-d6537129a33d"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{itemName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="390" y="0" width="80" height="20" uuid="eec1bb74-3a3b-4e3e-a946-f192c17129c2">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="93a5ea62-c6bc-4420-8220-beb00fa064c8"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{quantity}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="470" y="0" width="85" height="20" uuid="060897c5-c6bc-41db-b4bb-74f9b0930522">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="dde337f4-f033-42bb-8533-654ccdea99d0"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{unit}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="0" width="40" height="20" uuid="f5e5a0a4-ed77-4744-8aac-dd546115e273"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{COLUMN_COUNT}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
There's an additional closing ] in the XML fragment below:
<subreportExpression><![CDATA[$P{listOfItems}]]]></subreportExpression>
Remove it to fix the error:
<subreportExpression><![CDATA[$P{listOfItems}]]></subreportExpression>
subreportExpression element value represents the compiled sub report (.jasper) file name (file path with file name). it support to values from following classes,
java.lang.String (default)
java.io.File
java.io.InputStream
java.net.URL
JasperReport
in your case, declared a parameter as listOfItems with calss type java.util.ArrayList and it passed to subreportExpression. but java.util.ArrayList class type is not supported to subreportExpression
try with one of the following methods,
pass sub report name and sub report file path directly to subreportExpression.
<subreportExpression><![CDATA["Your Sub Report File Path/ItemsDetail.jasper"]]></subreportExpression> // sub report name is a ItemaDetail
declared a parameter with class type java.lang.String then, it pass to subreportExpression.
<parameter name="SUB_REPORT_FILE" class="java.lang.String"/>
<subreportExpression><![CDATA[$P{SUB_REPORT_FILE}]]></subreportExpression>
in run time you should pass the sub report file name to SUB_REPORT_FILE parameter in java application as given below,
HashMap<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("SUB_REPORT_FILE", "Your Sub Report File Path/ItemsDetail.jasper");
JasperPrint jasperPrint = JasperFillManager.fillReport("Your Master Report File Path/Invoice.jasper", parameterMap, YOUR_JRBeanCollectionDataSource); // master report name is a Invoice
or,
pass SUB_REPORT_FILE parameter with sub report file name to subreportExpression and set the sub report file path only at run time
in master report (Invoice.jrxml),
<subreportExpression><![CDATA[$P{SUB_REPORT_FILE}+"/ItemsDetail.jasper"]]></subreportExpression>
in java application,
HashMap<String, Object> parameterMap = new HashMap<String, Object>();
parameterMap.put("SUB_REPORT_FILE", "Your Sub Report File Path"); // pass the sub report file path only
JasperPrint jasperPrint = JasperFillManager.fillReport("Your Master
Report File Path/Invoice.jasper", parameterMap, YOUR_JRBeanCollectionDataSource);
Related
I try to give Persian text and numbers in xlsx. I want the numbers to be displayed in Arabic and Persian
As you can see, Persian font is applied and the numbers are in Persian but not so in xlsx
As you see font set but not applied On the other hand, the "B Farnaz" font is installed in the Windows operating system
<?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="rptReport"
pageWidth="842"
pageHeight="595"
orientation="Landscape"
columnWidth="802"
leftMargin="20"
rightMargin="20"
topMargin="20"
bottomMargin="20"
whenNoDataType="AllSectionsNoDetail">
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.2" value="pageFooter"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.3" value="title"/>
<property name="net.sf.jasperreports.crosstab.ignore.width" value="true"/>
<style name="textStyle" hTextAlign="Center" vTextAlign="Middle" fontName="B Farnaz" fontSize="10" pdfFontName= "C:/fonts/nazanin.ttf" pdfEncoding="Identity-H"/>
<parameter name="reportName" class="java.lang.String"/>
<parameter name="currentDate" class="java.lang.String"/>
<parameter name="number" class="java.lang.String"/>
<parameter name="pageName" class="java.lang.String"/>
<parameter name="ofName" class="java.lang.String"/>
<parameter name="logo" class="java.io.InputStream"/>
<field name="count" class="java.lang.Integer"/>
<field name="organizationId" class="java.lang.String"/>
<field name="orgName" class="java.lang.String"/>
<field name="orgCode" class="java.lang.String"/>
<field name="orgTypeName" class="java.lang.String"/>
<field name="positionId" class="java.lang.String"/>
<field name="title" class="java.lang.String"/>
<field name="orgParentName" class="java.lang.String"/>
<title>
<band height="61">
<rectangle>
<reportElement x="0" y="0" width="802" height="60" uuid="e0e43037-9be9-410e-9e49-9f03a811629b"/>
<graphicElement>
<pen lineWidth="0.75"/>
</graphicElement>
</rectangle>
<staticText>
<reportElement x="70" y="13" width="40" height="20" uuid="80c01bc2-7498-4a53-9183-9716832fa86e"/>
<textElement textAlignment="Left">
<font fontName="B Farnaz" size="14" pdfFontName= "C:/Users/m.shadkam/Desktop/PORTAL/portal-server/src/main/resources/report/fonts/nazanin.ttf" pdfEncoding="Identity-H"/>
</textElement>
<text><![CDATA[تاريخ :]]></text>
</staticText>
<staticText>
<reportElement x="70" y="35" width="40" height="20" uuid="df222e3e-0a63-4cff-8b4a-7b7d6cdad5b2"/>
<textElement textAlignment="Left">
<font fontName="B Farnaz" size="14" pdfFontName= "C:/Users/m.shadkam/Desktop/PORTAL/portal-server/src/main/resources/report/fonts/nazanin.ttf" pdfEncoding="Identity-H"/>
</textElement>
<text><![CDATA[شماره :]]></text>
</staticText>
<image hAlign="Right">
<reportElement x="690" y="13" width="110" height="44" uuid="6b166494-6df6-4472-8140-da4f93644616"/>
<imageExpression><![CDATA[$P{logo}]]></imageExpression>
</image>
<textField>
<reportElement x="3" y="35" width="65" height="20" uuid="52b5428c-f329-4d65-be61-51e529269ca7"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="B Farnaz" pdfFontName= "C:/fonts/BNAZANIN.TTF" pdfEncoding="Identity-H"/>
</textElement>
<textFieldExpression><![CDATA[$P{number}]]></textFieldExpression>
</textField>
<textField pattern="">
<reportElement x="0" y="1" width="802" height="35" uuid="c9904a66-50ba-4cee-9fa9-b6b29feec8b0"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="B Farnaz" size="14" pdfFontName= "C:/fonts/titr.ttf" pdfEncoding="Identity-H"/>
</textElement>
<textFieldExpression><![CDATA[$P{reportName}]]></textFieldExpression>
</textField>
<textField pattern="">
<reportElement x="3" y="13" width="65" height="20" uuid="fdc85694-ba29-4858-915e-23399415a806"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="B Farnaz" pdfFontName= "C:/fonts/BNAZANIN.TTF" pdfEncoding="Identity-H"/>
</textElement>
<textFieldExpression><![CDATA[$P{currentDate}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="20">
<textField>
<reportElement x="739" y="0" width="63" height="20" />
<textElement textAlignment="Right">
<font fontName="B Farnaz" pdfFontName="C:/fonts/BNAZANIN.TTF" pdfEncoding="Identity-H"/>
</textElement>
<textFieldExpression><![CDATA[$P{pageName} + " " + $V{PAGE_NUMBER} + " " + $P{ofName} +" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<pageFooter>
<band height="23" splitType="Stretch">
<textField>
<reportElement x="0" y="2" width="802" height="20" uuid="b8f61bae-86d8-4a73-8c23-3484b431a65e"/>
<textElement textAlignment="Center">
<font fontName="B Farnaz" pdfFontName= "C:/fonts/BNAZANIN.TTF" pdfEncoding="Identity-H"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height = "79">
<crosstab ignoreWidth="true">
<reportElement x="0" y="0" height="79" width="500"/>
<crosstabHeaderCell>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="100" y="0" width="100" height="100" />
<box>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textFieldExpression><![CDATA["اداره امور"]]></textFieldExpression>
</textField>
<textField>
<reportElement style="textStyle" x="0" y="0" width="100" height="100" />
<box>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textFieldExpression><![CDATA["واحد/کادر"]]></textFieldExpression>
</textField>
</cellContents>
</crosstabHeaderCell>
<rowGroup name="orgName" width="100" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{orgName}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="100" height="25" uuid="722e2c03-df3c-4012-aecf-91b7a8bad18d"/>
<textFieldExpression><![CDATA[$V{orgName}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement style="textStyle" x="0" y="0" width="200" height="25" uuid="4e9afca3-c0a3-4182-b3ce-9afb39fd3468"/>
<text><![CDATA[کل]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<rowGroup name="orgParentName" width="100" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{orgParentName}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="100" height="25" uuid="63804c09-f3f6-401f-8598-fa2e35860a8f"/>
<textFieldExpression><![CDATA[$V{orgParentName}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="title" height="100" totalPosition="End">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{title}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents backcolor="#F0F8FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="25" height="100" uuid="7edd05fd-4252-404d-bb82-54a705040663"/>
<textElement rotation="Left"/>
<textFieldExpression><![CDATA[$V{title}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement style="textStyle" x="0" y="0" width="25" height="100" uuid="de037370-9595-4ab0-8d55-ec94159f9ca0"/>
<textElement rotation="Left"/>
<text><![CDATA[کل]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="countMeasure" class="java.lang.Integer" calculation="Sum">
<measureExpression><![CDATA[$F{count}]]></measureExpression>
</measure>
<crosstabCell width="25" height="25">
<cellContents>
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="25" height="25" uuid="2de587ed-74f0-46c2-8425-5a4e9bd120e6"/>
<textFieldExpression><![CDATA[$V{countMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="25" rowTotalGroup="orgName">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="25" height="25" uuid="e7dd4c40-847f-4df0-b910-f99566746ecb"/>
<textFieldExpression><![CDATA[$V{countMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="25" columnTotalGroup="title">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="25" height="25" uuid="2ed6a617-5440-4bee-931e-dc4e16f0539d"/>
<textFieldExpression><![CDATA[$V{countMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell rowTotalGroup="orgName" columnTotalGroup="title">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
<textField>
<reportElement style="textStyle" x="0" y="0" width="25" height="25"/>
<textFieldExpression><![CDATA[$V{countMeasure}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell height="0" rowTotalGroup="orgParentName">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
</cellContents>
</crosstabCell>
<crosstabCell height="0" rowTotalGroup="orgParentName" columnTotalGroup="title">
<cellContents backcolor="#BFE1FF" mode="Opaque">
<box>
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
</box>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>
I used Persian font in the report, but this Persian font is not applied in the xlsx version of the report, but is applied correctly in the pdf version.
I also used the font exception to solve this problem but it did not work for the excel version.
Please help me to display the text and numbers in xlsx like pdf correctly
According to my design requirement, I am trying to create a simple Jasper report( using Jasper-soft Studio in 6.12 version) with Table in which the main report and table should be populated by java code using JRResultSetDataSource object with same query execution or data-source and also calculating the record count in page header, of the number of rows fetched in the table from the database.
But the problem is that- Either only table is getting populated through the data Source or only main report is getting populated or while providing same data-source to both main report and table then the first record of the table is missing because the record pointer in the data source is incremented as the data-source is passed from main report to table. Nor am I able to clone the data source to provide a copy of the data-source to the table as it is not supported for JRResultSetDataSource.
I want to use the same data-source to populate the table and to populate text fields present in the main report.
Java code-
Connection con;
Statement stmt;
ResultSet rs;
try {
Class.forName("org.postgresql.Driver");
con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/jasperexamples", "postgres", "password");
stmt=con.createStatement();
String query= "select * from product";
rs=stmt.executeQuery(query);
JRResultSetDataSource rsdt = new JRResultSetDataSource(rs);
String jasperReport = "/home/sakshi/JaspersoftWorkspace/MyReports/JasperProduct.jasper";
JasperPrint jp1 = JasperFillManager.fillReport(jasperReport, new HashMap<String, Object>(),rsdt);
JasperViewer jv = new JasperViewer(jp1);
jv.setVisible(true);
con.close();
}
catch(Exception e) {
e.printStackTrace();
}
Jrxml code-
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="JasperProduct" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0d6d7195-8cff-4512-be5d-258e505e6836">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Dataset1" uuid="0dc50125-a9d2-458b-82aa-27bfa253f3e9">
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="prouductname" class="java.lang.String"/>
<field name="productprize" class="java.lang.String"/>
<field name="company" class="java.lang.String"/>
</subDataset>
<queryString>
<![CDATA[]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="prouductname" class="java.lang.String"/>
<field name="productprize" class="java.lang.String"/>
<field name="company" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<staticText>
<reportElement x="0" y="20" width="802" height="30" uuid="463c4bc3-254d-4c78-a35e-0096dc006165"/>
<box leftPadding="5"/>
<textElement verticalAlignment="Middle">
<font size="24"/>
</textElement>
<text><![CDATA[Product Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="55" splitType="Stretch">
<staticText>
<reportElement x="5" y="17" width="110" height="30" uuid="836aa66c-e052-4ca1-ac75-feb821efa866"/>
<textElement verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Report Count]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement x="125" y="17" width="100" height="30" uuid="500a4853-c045-4897-a007-6e77598a31c7"/>
<textElement verticalAlignment="Middle">
<font size="14"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<detail>
<band height="199" splitType="Stretch">
<componentElement>
<reportElement x="0" y="34" width="802" height="126" uuid="dc722ea3-7c31-439b-996c-bb3892426aea">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
<property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/>
</reportElement>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Dataset1" uuid="2c3773b9-e3a5-4046-a9d7-825487945fbb">
<datasetParameter name="REPORT_DATA_SOURCE">
<datasetParameterExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
<jr:columnGroup width="802" uuid="35fb663c-fc50-45f9-8715-575fe5aa27f4">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [4]"/>
<jr:tableHeader style="Table_TH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="802" height="30" uuid="9cdc6108-4308-449a-9995-182837f26b4d"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="18"/>
</textElement>
<text><![CDATA[Product Details]]></text>
</staticText>
</jr:tableHeader>
<jr:columnGroup width="802" uuid="2282f969-105d-4cf7-9714-ce0eef6e7a2a">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [4]"/>
<jr:tableFooter style="Table_TH" height="30" rowSpan="1">
<textField textAdjust="StretchHeight">
<reportElement mode="Opaque" x="0" y="0" width="802" height="30" uuid="4aa3d9f1-22dd-44bb-b002-b1fc83349c66"/>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:column width="200" uuid="88208a30-4a0d-4a22-8558-c9347efcab95">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="200" height="30" uuid="c7b0da69-05cb-4e00-b215-501476c06697"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="200" height="30" uuid="69c964ef-8985-4b28-adf2-eb89663ffa3c"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="190" uuid="26ed996c-7261-48e1-bfdd-5492a313bee9">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="190" height="30" uuid="294980bc-20b3-472e-999f-5be40daacf01"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Product Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="190" height="30" uuid="30e24e73-2357-40a9-ba78-a8dff9938ab9"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{prouductname}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="220" uuid="efd0925b-65d3-438e-950c-95fefc05998e">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
<jr:columnHeader style="Table_CH" height="30" rowSpan="1">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="220" height="30" uuid="1480c534-2f5f-4cc7-96be-e275415b8cd0"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true" isItalic="false"/>
</textElement>
<text><![CDATA[Product Prize]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="220" height="30" uuid="2df7f400-4845-4ebe-a874-c3ae91ccba2e"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{productprize}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="192" uuid="dfd8aead-b732-4300-8a47-29b0a6b7605b">
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
<jr:columnHeader style="Table_CH" height="30">
<staticText>
<reportElement mode="Opaque" x="0" y="0" width="192" height="30" uuid="7fac6d69-f0eb-4ff2-82de-152872d9930d"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Company]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="Table_TD" height="30">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="192" height="30" uuid="701bebcf-d200-4cf8-bd88-37f4578be852"/>
<box leftPadding="3"/>
<textElement verticalAlignment="Middle">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{company}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</jr:columnGroup>
</jr:table>
</componentElement>
</band>
</detail>
<pageFooter>
<band height="62">
<staticText>
<reportElement x="0" y="20" width="160" height="30" uuid="dca10f20-8fa6-4e1b-8d48-16b549783ac6"/>
<box leftPadding="3">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement verticalAlignment="Middle">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[Company Name: ]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement x="160" y="20" width="642" height="30" uuid="2e69e42c-7588-429b-a0dc-42042e24bd61"/>
<box leftPadding="3">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement verticalAlignment="Middle">
<font size="13"/>
</textElement>
<textFieldExpression><![CDATA[$F{company}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
</jasperReport>
I have seen different approaches-
add a first empty row to the datasource before passing it to the
report.
passing two data sources- one to table and one to main
report.(But both work on the same datasource so it reduces the
performance).
But I don't think these approaches are good.
And also referred to different references but they didn't work according to my design requirement-
Why is my subdataset blank when I run report from Java code?
http://zetcode.com/articles/jaspertable/
http://junaedhalim.blogspot.com/2009/12/creating-jasperreport-with-subreports.html
https://community.jaspersoft.com/questions/540719/resolved-table-report-missing-1st-tablemodel-row
https://community.jaspersoft.com/questions/817326/table-not-displaying-any-values
Jasper Reports how to set data from JRResultSetDataSource into Table component
Can anyone please suggest a better approach for resolving this issue.
Thanks in advance
Recently I've come up to some question related to calendar report in iReport.
This is the link I referenced to create a calendar:
Sample Report to Create a Monthly Calendar
With the above reference, I created a calendar report that can display court attendance record corresponding to different dates:
<?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="CourtCaseSchedule" language="groovy" columnCount="7" pageWidth="2170" pageHeight="500" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="310" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="4bd402ec-2e5b-4f79-bfb6-69da329d8fe7">
<property name="ireport.zoom" value="0.9090909090909121"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="style1">
<conditionalStyle>
<conditionExpression><![CDATA[$V{COLUMN_NUMBER} % 7 == 1]]></conditionExpression>
<style forecolor="#FF3333" backcolor="#FFFFFF">
<pen lineColor="#000000"/>
</style>
</conditionalStyle>
</style>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#FFBFBF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="6d06249f-027b-4ca5-b2af-256229b56b96"/>
<parameter name="REPORT_MONTH" class="java.lang.String"/>
<parameter name="REPORT_YEAR" class="java.lang.String"/>
<parameter name="srCCS_ReportDataSourceDetailsList" class="java.util.List"/>
<parameter name="srCCS_JasperReportDetails" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Reports\\"]]></defaultValueExpression>
</parameter>
<field name="rCCSDayofWeek" class="java.lang.String"/>
<field name="rCCSDate" class="java.lang.String"/>
<variable name="SUBREPORT_INDEX" class="java.lang.Integer" incrementType="Column">
<variableExpression><![CDATA[$F{rCCSDate}]]></variableExpression>
<initialValueExpression><![CDATA[1]]></initialValueExpression>
</variable>
<title>
<band height="75" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#FF3333" uuid="f86c7aa5-b2fa-4668-aaa4-3f3660d37655"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Sunday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="310" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="fc91553f-de51-43f6-8cfa-fcf5d5dbbd2c"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Monday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="620" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="487a8ddb-6029-4c65-8a40-afabdb55d613"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Tuesday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="930" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="c9a33cdb-66de-47a7-a350-d2a7672ec3ce"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Wednesday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1240" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="0555ba56-fd4c-4f02-b0a2-c51945547af4"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Thursday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1550" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="62afe59e-0dda-4b68-89d0-5e3bc6dbf1f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Friday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1860" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="56f14a13-3fe0-41c2-827b-8cbce1234467"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Saturday]]></text>
</staticText>
<textField>
<reportElement x="0" y="0" width="2170" height="43" uuid="2772960e-b50a-4f5f-a80a-56aa8e28891a"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="32" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Court Case Schedule of " + $P{REPORT_MONTH} + " " + $P{REPORT_YEAR}]]></textFieldExpression>
</textField>
</band>
</title>
<detail>
<band height="300" splitType="Stretch">
<frame>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="310" height="300" uuid="cd88766b-0047-4150-b29c-2e7227fbb00c"/>
<textField>
<reportElement style="style1" positionType="Float" mode="Transparent" x="0" y="0" width="68" height="58" uuid="293e7d8e-d54f-4776-9311-7d9f0270d573">
<printWhenExpression><![CDATA[$F{rCCSDayofWeek}.isEmpty() || $F{rCCSDayofWeek}.equals(java.lang.Integer.toString($V{COLUMN_NUMBER}))]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="28" isBold="true"/>
<paragraph leftIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{rCCSDate}]]></textFieldExpression>
</textField>
<subreport>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="58" width="310" height="242" uuid="f8fcd85a-d8cf-4b88-b563-652f6d13351d"/>
<dataSourceExpression><![CDATA[$P{srCCS_ReportDataSourceDetailsList}.get($V{REPORT_COUNT}-1)]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "CourtCaseSchedule_SubReport.jasper"]]></subreportExpression>
</subreport>
</frame>
</band>
</detail>
</jasperReport>
This report simply generates a monthly calendar with a sub-report in each cell, where the sub-report displays the court attendance information according to each date.
The problem now is, with the fixed page height of the main report, when there's too many rows inside the sub-report and its heights overflows the page height of the main report, it automatically switches to the next column of the report. As a result the report will become malformed. I've looked for various solution for the overflow issue but none of them worked. Can someone enlighten me to have a workaround for this?
Here are some attributes that are available in Jasper that I've tried:
Position Type: Float
Report Split Type: Stretch
Include row and column attribute inside the report element from net.sf.jasperreports.export.xls.auto.fit
Setting detail band height during runtime
Finally turned away from Jasperreports, and I managed to switch the implementation to poi. In this case the Excel configuration could be a bit more flexible based on my needs.
Conclusion: Jasper is not quite capable in creating content included calendar!
I am a newbie to JasperReports. When I try to add values to table in the columns the column header and footer are getting repeated. How should I group column header.
My 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="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="551344a1-61b0-419c-92a0-5ebe6f8d4219">
<property name="ireport.zoom" value="1.2100000000000004"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="75c6059a-1e76-45b2-a87c-14792e68956e">
<field name="training" class="java.lang.String"/>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
</subDataset>
<parameter name="ReportName" class="java.lang.String"/>
<parameter name="Date" class="java.lang.String"/>
<parameter name="Title" class="java.lang.String"/>
<parameter name="SubTitle" class="java.lang.String"/>
<parameter name="FooterDetail" class="java.lang.String"/>
<parameter name="govtlogo" class="java.lang.String"/>
<parameter name="TNWRDLogo" class="java.lang.String"/>
<field name="training" class="java.lang.String">
<fieldDescription><![CDATA[training]]></fieldDescription>
</field>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch">
<frame>
<reportElement uuid="fd5eaed7-88e8-4980-8205-6e50cf99ef20" x="0" y="27" width="565" height="52">
<property name="net.sf.jasperreports.export.pdf.tag.h1"/>
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textField>
<reportElement uuid="d3615141-0461-4665-b5f4-46a10f968d0e" x="174" y="33" width="213" height="19"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{SubTitle}]]></textFieldExpression>
</textField>
<image>
<reportElement uuid="34b5159e-3eb2-450a-9536-f79813589d48" x="442" y="2" width="61" height="48"/>
<imageExpression><![CDATA[$P{TNWRDLogo}]]></imageExpression>
</image>
<image>
<reportElement uuid="cd0f7d86-105f-44a1-8c27-81feacfba469" x="65" y="0" width="98" height="51"/>
<imageExpression><![CDATA[$P{govtlogo}]]></imageExpression>
</image>
<textField>
<reportElement uuid="e8aee322-2336-4637-9a5c-cb51af5995c8" x="174" y="0" width="213" height="32"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement uuid="4c89127c-2b66-447e-af83-7ffd210e8a19" x="174" y="5" width="213" height="24"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{ReportName}]]></textFieldExpression>
</textField>
<frame>
<reportElement uuid="4ba70858-74c9-48a0-9690-888636570607" x="0" y="0" width="565" height="35"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
</frame>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<staticText>
<reportElement uuid="479cad61-a5be-4318-8e81-850ba6626e59" x="27" y="0" width="100" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training Detail]]></text>
</staticText>
<staticText>
<reportElement uuid="d3474389-b724-4579-81b6-2f5c806aaa25" x="432" y="0" width="100" height="22"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Special Tests Passed]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="f2abf631-2415-4ba1-bf93-4b1d458dacbc" key="table 2" style="table 2" x="53" y="44" width="450" height="50"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1" uuid="69dfdbc6-34fc-48ee-8ecd-197cde9b11fb">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
</datasetRun>
<jr:columnGroup width="450" uuid="7287994d-bc5c-4286-8607-29969a2eb9ef">
<jr:column width="90" uuid="dbd24c78-fb82-47c4-9342-d5a73fb7e000">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="74b27263-d281-4136-b674-12bd3a74bd3c" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="be34b5c1-5cd4-43e3-b6f9-0e6f2bbf88db" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{training}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="01a9c90b-46c3-4693-b186-7abc77256f73">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="5ada3627-2084-4d79-a923-b6acbeee8058" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Period / Duration]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="abb64036-38ea-4560-84fd-09dde730c3bc" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{trainingPeriod}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="0865e4a3-5dbe-430a-9c50-90a636ef49ef">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="a897110e-f09f-43f3-a53b-aa8450065832" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Impart Training Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="41f45483-1f6d-480c-a59c-96093111ace5" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{traingingAdd}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="8949efe8-7041-49dd-8631-685e8568e6d5">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="643bb124-0b66-448d-ade8-c7b540f18eb5" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[No of Government Orders]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="834227d7-673a-4335-b1f8-37b3892125b1" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{noofgovtorderauth}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="7fa15b45-3110-4648-ab41-35fc77c625d6">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="cfd20c24-75f4-449e-83ae-38d9e0507728" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[ Approving Audthority]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="b5e5dec0-46d3-47b5-aefe-5fe2038c94b9" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{authapprovingentry}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Try this , It will work for you.
<?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="report1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="551344a1-61b0-419c-92a0-5ebe6f8d4219">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 1_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table 2_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="75c6059a-1e76-45b2-a87c-14792e68956e">
<field name="training" class="java.lang.String"/>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
</subDataset>
<parameter name="ReportName" class="java.lang.String"/>
<parameter name="Date" class="java.lang.String"/>
<parameter name="Title" class="java.lang.String"/>
<parameter name="SubTitle" class="java.lang.String"/>
<parameter name="FooterDetail" class="java.lang.String"/>
<parameter name="govtlogo" class="java.lang.String"/>
<parameter name="TNWRDLogo" class="java.lang.String"/>
<field name="training" class="java.lang.String">
<fieldDescription><![CDATA[training]]></fieldDescription>
</field>
<field name="trainingPeriod" class="java.lang.String"/>
<field name="traingingAdd" class="java.lang.String"/>
<field name="noofgovtorderauth" class="java.lang.String"/>
<field name="authapprovingentry" class="java.lang.String"/>
<field name="deptTestpassed" class="java.lang.String"/>
<field name="athConducTest" class="java.lang.String"/>
<field name="monthSptestPassed" class="java.lang.String"/>
<field name="yrSpTestPassed" class="java.lang.String"/>
<field name="regNo" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="114" splitType="Stretch">
<frame>
<reportElement uuid="fd5eaed7-88e8-4980-8205-6e50cf99ef20" x="0" y="27" width="565" height="52">
<property name="net.sf.jasperreports.export.pdf.tag.h1"/>
<property name="net.sf.jasperreports.export.pdf.tag.tr" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.th" value="full"/>
<property name="net.sf.jasperreports.export.pdf.tag.td" value="full"/>
</reportElement>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
<textField>
<reportElement uuid="d3615141-0461-4665-b5f4-46a10f968d0e" x="174" y="33" width="213" height="19"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{SubTitle}]]></textFieldExpression>
</textField>
<image>
<reportElement uuid="34b5159e-3eb2-450a-9536-f79813589d48" x="442" y="2" width="61" height="48"/>
<imageExpression><![CDATA[$P{TNWRDLogo}]]></imageExpression>
</image>
<image>
<reportElement uuid="cd0f7d86-105f-44a1-8c27-81feacfba469" x="65" y="0" width="98" height="51"/>
<imageExpression><![CDATA[$P{govtlogo}]]></imageExpression>
</image>
<textField>
<reportElement uuid="e8aee322-2336-4637-9a5c-cb51af5995c8" x="174" y="0" width="213" height="32"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
</frame>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<textField>
<reportElement uuid="4c89127c-2b66-447e-af83-7ffd210e8a19" x="174" y="5" width="213" height="24"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="9" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{ReportName}]]></textFieldExpression>
</textField>
<frame>
<reportElement uuid="4ba70858-74c9-48a0-9690-888636570607" x="0" y="0" width="565" height="35"/>
<box>
<pen lineWidth="0.25"/>
<topPen lineWidth="0.25"/>
<leftPen lineWidth="0.25"/>
<bottomPen lineWidth="0.25"/>
<rightPen lineWidth="0.25"/>
</box>
</frame>
</band>
</pageHeader>
<columnHeader>
<band height="23" splitType="Stretch">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
<staticText>
<reportElement uuid="479cad61-a5be-4318-8e81-850ba6626e59" x="27" y="0" width="100" height="22">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training Detail]]></text>
</staticText>
<staticText>
<reportElement uuid="d3474389-b724-4579-81b6-2f5c806aaa25" x="432" y="0" width="100" height="22">
<printWhenExpression><![CDATA[$V{REPORT_COUNT} == 1]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Special Tests Passed]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement uuid="f2abf631-2415-4ba1-bf93-4b1d458dacbc" key="table 2" style="table 2" x="53" y="44" width="450" height="50"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="Table Dataset 1" uuid="69dfdbc6-34fc-48ee-8ecd-197cde9b11fb">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource(1)]]></dataSourceExpression>
</datasetRun>
<jr:columnGroup uuid="7287994d-bc5c-4286-8607-29969a2eb9ef" width="450">
<jr:column uuid="dbd24c78-fb82-47c4-9342-d5a73fb7e000" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="74b27263-d281-4136-b674-12bd3a74bd3c" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Training]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="be34b5c1-5cd4-43e3-b6f9-0e6f2bbf88db" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{training}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="01a9c90b-46c3-4693-b186-7abc77256f73" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="5ada3627-2084-4d79-a923-b6acbeee8058" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Period / Duration]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="abb64036-38ea-4560-84fd-09dde730c3bc" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{trainingPeriod}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="0865e4a3-5dbe-430a-9c50-90a636ef49ef" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="a897110e-f09f-43f3-a53b-aa8450065832" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Impart Training Address]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="41f45483-1f6d-480c-a59c-96093111ace5" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{traingingAdd}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="8949efe8-7041-49dd-8631-685e8568e6d5" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="643bb124-0b66-448d-ade8-c7b540f18eb5" positionType="Float" stretchType="RelativeToBandHeight" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[No of Government Orders]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="834227d7-673a-4335-b1f8-37b3892125b1" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{noofgovtorderauth}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column uuid="7fa15b45-3110-4648-ab41-35fc77c625d6" width="90">
<jr:columnHeader style="table 2_CH" height="29" rowSpan="1">
<staticText>
<reportElement uuid="cfd20c24-75f4-449e-83ae-38d9e0507728" x="0" y="0" width="90" height="29"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[ Approving Audthority]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table 2_TD" height="30" rowSpan="1">
<textField>
<reportElement uuid="b5e5dec0-46d3-47b5-aefe-5fe2038c94b9" x="0" y="0" width="90" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{authapprovingentry}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:columnGroup>
</jr:table>
</componentElement>
</band>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Enjoy....
I am trying to create a watermark with a text in a report. For e.g. have a text like this is a good report printed horizontally repeatedly at the background of a report. I know this can be done in the background band but don't know how.
UPDATE
Your solution worked. I want to implement this in another way. I want to print the same text repeatedly at the background. Let's say i want to print the text welcome to a new year. I will want it to print this way
welcome to a new year welcome to a new year welcome to a new year welcome to a new year
welcome to a new year welcome to a new year welcome to a new year welcome to a new year
welcome to a new year welcome to a new year welcome to a new year welcome to a new year
welcome to a new year welcome to a new year welcome to a new year welcome to a new year
welcome to a new year welcome to a new year welcome to a new year welcome to a new year
...
All these will be at the background. Can i achieve something like this without manually creating the text fields to fill the page.
Yes, you are right. You can use Background band for printing watermark text (or picture).
You should set the height for this band - I think it is better to set height of this band the same as the report's height.
For example, for A4 format I have set the 802 pixels for Background's band height. The formula for calculating this number was: the Report's height (842 pixels for A4 format) - the Left Margin's width (20 in my case) - the Right Margin's width (20 in my case).
After setting size for the Background band you can put image or staticText (textField) elements to this (Background) band.
You can rotate the text of staticText (textField) element with help of rotation attribute. The available values of this attribites are:
None (no rotation - 0 degrees),
Left (rotate 270 degrees),
Right (rotate 90 degrees),
UpsideDown (rotate 180 degrees).
In the working sample I've used styles for setting the rotation attribute for textField and for one element I've set value for this attribute directly to the textField element:
<?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="watermark_sample" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bc290dd1-903c-4740-8484-16a2ebe872d2">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Rotated180" mode="Opaque" forecolor="#FF33CC" hAlign="Center" vAlign="Middle" rotation="UpsideDown" fontName="Curlz MT" fontSize="40"/>
<style name="Rotated270" mode="Opaque" forecolor="#FF33CC" hAlign="Center" vAlign="Middle" rotation="Left" fontName="Curlz MT" fontSize="40"/>
<style name="Rotated90" mode="Opaque" forecolor="#FF33CC" hAlign="Center" vAlign="Middle" rotation="Right" fontName="Curlz MT" fontSize="40"/>
<style name="NotRotated" mode="Opaque" forecolor="#FF33CC" hAlign="Center" vAlign="Middle" rotation="None" fontName="Curlz MT" fontSize="40"/>
<queryString>
<![CDATA[SELECT ID, NAME, COST FROM PRODUCT ORDER BY NAME]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="NAME" class="java.lang.String"/>
<field name="COST" class="java.math.BigDecimal"/>
<background>
<band height="802" splitType="Stretch">
<image hAlign="Center">
<reportElement uuid="42c96db8-4afd-4834-ba69-6b211df0c42f" style="Rotated180" mode="Opaque" x="118" y="372" width="318" height="58"/>
<imageExpression><![CDATA["D:\\java\\jasper_reports\\happy_new_year_h.png"]]></imageExpression>
</image>
<staticText>
<reportElement uuid="d7401e33-f1b3-49ca-85d1-2923d82508f6" style="NotRotated" x="106" y="22" width="342" height="63"/>
<textElement/>
<text><![CDATA[Happy New Year!]]></text>
</staticText>
<staticText>
<reportElement uuid="d7401e33-f1b3-49ca-85d1-2923d82508f6" style="Rotated270" x="24" y="236" width="93" height="330"/>
<textElement/>
<text><![CDATA[Happy New Year!]]></text>
</staticText>
<staticText>
<reportElement uuid="d7401e33-f1b3-49ca-85d1-2923d82508f6" style="Rotated90" x="445" y="236" width="93" height="330"/>
<textElement/>
<text><![CDATA[Happy New Year!]]></text>
</staticText>
<staticText>
<reportElement uuid="d7401e33-f1b3-49ca-85d1-2923d82508f6" style="Rotated180" x="106" y="702" width="342" height="63"/>
<textElement/>
<text><![CDATA[Happy New Year!]]></text>
</staticText>
<staticText>
<reportElement uuid="3bdd5d67-94f0-457f-8477-b1d0438d7bc9" mode="Opaque" x="79" y="85" width="428" height="139" forecolor="#9999FF"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="Right">
<font fontName="Edwardian Script ITC" size="40" isItalic="true"/>
</textElement>
<text><![CDATA[Happy New Year!]]></text>
</staticText>
</band>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="6d708618-09e4-433d-ab48-bb9cbd0b832b" x="92" y="29" width="370" height="20"/>
<textElement>
<font size="14" isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Sample of report with watermark]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="0" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="200" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Cost]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="100" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="0" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="200" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{COST}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The image element does not support the rotation attribute, but you can create any image you want manually.
Note: in this sample I've used mode="Opaque" for textField and image elements.
The result will be (via iReport preview function):
For solving your case (several texts as watermark) I've put several textField elements to the Background band. The report's template is:
<?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="watermark_sample" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bc290dd1-903c-4740-8484-16a2ebe872d2">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="68"/>
<queryString>
<![CDATA[SELECT ID, NAME, COST FROM PRODUCT ORDER BY NAME]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="NAME" class="java.lang.String"/>
<field name="COST" class="java.math.BigDecimal"/>
<background>
<band height="802" splitType="Stretch">
<staticText>
<reportElement uuid="3bdd5d67-94f0-457f-8477-b1d0438d7bc9" mode="Transparent" x="63" y="112" width="428" height="56" forecolor="#808080"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">
<font fontName="Serif" size="40" isItalic="true"/>
</textElement>
<text><![CDATA[this is a good report]]></text>
</staticText>
<staticText>
<reportElement uuid="3bdd5d67-94f0-457f-8477-b1d0438d7bc9" mode="Transparent" x="63" y="272" width="428" height="56" forecolor="#808080"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">
<font fontName="Serif" size="40" isItalic="true"/>
</textElement>
<text><![CDATA[this is a good report]]></text>
</staticText>
<staticText>
<reportElement uuid="3bdd5d67-94f0-457f-8477-b1d0438d7bc9" mode="Transparent" x="63" y="432" width="428" height="56" forecolor="#808080"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">
<font fontName="Serif" size="40" isItalic="true"/>
</textElement>
<text><![CDATA[this is a good report]]></text>
</staticText>
<staticText>
<reportElement uuid="3bdd5d67-94f0-457f-8477-b1d0438d7bc9" mode="Transparent" x="63" y="594" width="428" height="56" forecolor="#808080"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None">
<font fontName="Serif" size="40" isItalic="true"/>
</textElement>
<text><![CDATA[this is a good report]]></text>
</staticText>
</band>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="6d708618-09e4-433d-ab48-bb9cbd0b832b" x="92" y="29" width="370" height="20"/>
<textElement>
<font size="14" isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Sample of report with watermark]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="0" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="200" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Cost]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="100" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="0" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="200" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{COST}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
Note: in this sample I've used mode="Transparent" for textField elements.
The report's design (in iReport):
The result will be (via iReport preview function):
You can find more information in Watermark across the page in JasperReports post if you want to set custom rotation angle.
UPDATE: You can solve your second issue, for example, with help of StringUtils.repeat(java.lang.String, int) method from Commons Lang API.
You can add import instruction (<import value="org.apache.commons.lang3.StringUtils"/> in my sample) to your report's template and use the expression like this:
<textFieldExpression><![CDATA[StringUtils.repeat("Welcome to a New Year! ", $P{numberOfRepeats})]]></textFieldExpression>
The 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="watermark_sample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bc290dd1-903c-4740-8484-16a2ebe872d2">
<import value="org.apache.commons.lang3.StringUtils"/>
<parameter name="numberOfRepeats" class="java.lang.Integer" isForPrompting="false">
<defaultValueExpression><![CDATA[10]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT ID, NAME, COST FROM PRODUCT ORDER BY NAME]]>
</queryString>
<field name="ID" class="java.lang.Integer"/>
<field name="NAME" class="java.lang.String"/>
<field name="COST" class="java.math.BigDecimal"/>
<background>
<band height="802" splitType="Stretch">
<textField isStretchWithOverflow="true">
<reportElement uuid="26290245-c5cf-4f28-b637-c5b0253910a5" mode="Transparent" x="21" y="112" width="470" height="56" forecolor="#808080"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" markup="none">
<font fontName="Serif" size="20" isItalic="true"/>
</textElement>
<textFieldExpression><![CDATA[StringUtils.repeat("Welcome to a New Year! ", $P{numberOfRepeats})]]></textFieldExpression>
</textField>
</band>
</background>
<title>
<band height="79" splitType="Stretch">
<staticText>
<reportElement uuid="6d708618-09e4-433d-ab48-bb9cbd0b832b" x="92" y="29" width="370" height="20"/>
<textElement>
<font size="14" isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Sample of report with watermark]]></text>
</staticText>
</band>
</title>
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="0" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="200" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Cost]]></text>
</staticText>
<staticText>
<reportElement uuid="414160e2-41c4-4326-8ec8-ff7c230ac2c3" mode="Opaque" x="100" y="0" width="100" height="20" forecolor="#000000" backcolor="#3399FF"/>
<box leftPadding="10" rightPadding="10">
<topPen lineWidth="1.0"/>
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true" isItalic="true"/>
</textElement>
<text><![CDATA[Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="0" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{ID}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="100" y="0" width="100" height="20"/>
<box leftPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement/>
<textFieldExpression><![CDATA[$F{NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="5715c691-0b39-4530-9009-3b7179bb06f5" x="200" y="0" width="100" height="20"/>
<box leftPadding="10" rightPadding="10">
<leftPen lineWidth="1.0"/>
<bottomPen lineWidth="1.0"/>
<rightPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{COST}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
The result will be (via iReport preview function):
Details:
In this sample I've used the Commons Lang library v. 3.1. You should add this library to the application's classpath (in my case it was iReport's cp).
I've used the parameter numberOfRepeats (java.lang.Integer) for setting the number of phrases to generate.