Jasper SubReport doesnt' show in Master - jasper-reports

I asked a similar question a year ago and didn't discover a resolution. The subreport I am working on now is in the detail band of the master, although I did try it in others just in case.
<detail>
<band height="34" splitType="Stretch">
<subreport>
<reportElement stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" mode="Transparent" x="0" y="0" width="555" height="34" uuid="6318f4b9-c420-4294-a63f-1a83d338f755">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreportParameter name="item_id">
<subreportParameterExpression><![CDATA[$F{item_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["report.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
I checked the path to the subreport is correct. In the subreport the parameter_name is exactly the same. The .jasper file is compiled successfully.
The master report has a call to a stored procedure, and I am using one of the fields it is returning as the subreport parameter. I called it 'item_id' here. I used the wizard to map that to the subreport parameter with the same name. The idea is that the subreport should return additional information about each of the item_ids returned by the SP in the master report.
When I run the subreport on it's own it returns data for a particular item_id. I created a variable in the master to track how many rows the SP itself returns and when I run the master it shows the correct number of rows exist but no data displays on the master report. It also leaves enough empty space to appear to indicate that something is being returned but just not displayed. When I set 'remove line when blank' for the subreport element in properties from the master report I get no rows - so apparently it is returning a blank line 44 times - one for each row. Or is it?
One suggestion was to remove the connection_expression and replace it with parameters_map_expression but that didn't help either.
My best guess is that the subreport data is not getting to the master for some reason. If anyone has any suggestions I am open to anything I can do with JasperSoftStudio 6.3.
Master report:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 -->
<!-- 2016-09-07T10:21:37 -->
<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="ITEMMRPT" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1aa96e89-cb24-464e-90bf-0d12bc48a516">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="staging"/>
<parameter name="billing_year" class="java.lang.Integer">
<defaultValueExpression><![CDATA[2015]]></defaultValueExpression>
</parameter>
<parameter name="billing_month" class="java.lang.Integer">
<defaultValueExpression><![CDATA[9]]></defaultValueExpression>
</parameter>
<parameter name="billing_day" class="java.lang.Integer">
<defaultValueExpression><![CDATA[1]]></defaultValueExpression>
</parameter>
<parameter name="report_type" class="java.lang.String">
<defaultValueExpression><![CDATA["DAILY"]]></defaultValueExpression>
</parameter>
<parameter name="area_cd" class="java.lang.String">
<defaultValueExpression><![CDATA["TACM"]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[exec createitembillingReport;1 #billing_year = $P{billing_year}, #billing_month = $P{billing_month}, #billing_day = $P{billing_day},#report_type=$P{report_type},#area_cd = $P{area_cd}]]>
</queryString>
<field name="item_id" class="java.lang.String"/>
<field name="item_name" class="java.lang.String"/>
<variable name="total" class="java.lang.Integer" calculation="Count">
<variableExpression><![CDATA[$F{item_id}]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="67">
<staticText>
<reportElement x="60" y="33" width="242" height="17" uuid="06a14aaf-07b9-4894-bc60-0f5b3b254826">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="11"/>
</textElement>
<text><![CDATA[Item Listing]]></text>
</staticText>
<staticText>
<reportElement x="60" y="50" width="78" height="17" uuid="365238e1-9e5f-471b-92aa-aadab4fcfc31">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="11" isBold="true"/>
</textElement>
<text><![CDATA[Billable as of :]]></text>
</staticText>
<textField>
<reportElement x="138" y="50" width="180" height="17" uuid="c735ec59-4e96-4b22-bf70-08af130efed9"/>
<textElement>
<font size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{billing_month}+"/"+$P{billing_day}+"/"+$P{billing_year}]]></textFieldExpression>
</textField>
</band>
</title>
<columnHeader>
<band height="18">
<staticText>
<reportElement x="16" y="0" width="70" height="17" uuid="79476ab9-e5ea-40ec-b382-b22a0c5d355a">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Item ID]]></text>
</staticText>
<staticText>
<reportElement x="479" y="0" width="61" height="17" uuid="adb588f3-ed71-439a-acde-d812acee6a94">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Location]]></text>
</staticText>
<staticText>
<reportElement x="260" y="0" width="97" height="17" uuid="243ce68e-c532-4056-958e-08f7a0f83d2a">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Pull Date]]></text>
</staticText>
<staticText>
<reportElement x="89" y="0" width="87" height="17" uuid="ca299eb7-2aba-4529-ae76-3dfa4c6abe29">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Order Date]]></text>
</staticText>
<staticText>
<reportElement x="380" y="0" width="86" height="17" uuid="c220e72b-bd29-416a-95fc-c6c8a10ab081">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Ship Date]]></text>
</staticText>
<staticText>
<reportElement x="168" y="0" width="92" height="17" uuid="2ea414c5-4484-48dc-a6b5-52d4ab3ebd97">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Description]]></text>
</staticText>
<line>
<reportElement x="0" y="17" width="555" height="1" uuid="ab7d193f-96d3-454a-8fdd-5e0027425d42">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<subreport>
<reportElement isPrintRepeatedValues="false" mode="Transparent" x="0" y="4" width="555" height="16" uuid="6318f4b9-c420-4294-a63f-1a83d338f755">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreportParameter name="item_id">
<subreportParameterExpression><![CDATA[$F{item_id}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["report.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="10" y="-1" width="100" height="16" uuid="91285585-7366-46c3-b248-9dbaf0c80839"/>
<textFieldExpression><![CDATA[$F{item_id}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="15">
<textField>
<reportElement x="110" y="0" width="100" height="15" uuid="54e9321a-c062-49f4-8b32-02f4c41458c0"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="210" y="0" width="100" height="15" uuid="00b215e9-ba28-413b-ad44-4c4a3aac7fdd"/>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="400" y="-1" width="50" height="15" uuid="0dae2a30-28fe-4a71-9dc9-ec906ec05c78"/>
<text><![CDATA[Run Date :]]></text>
</staticText>
<textField pattern="MMMMM dd, yyyy">
<reportElement x="450" y="1" width="100" height="13" uuid="34cfa033-e43d-4668-852d-3019f322ea5a"/>
<textFieldExpression><![CDATA[new SimpleDateFormat("MMM dd, yyyy").format(TODAY())]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="18">
<textField>
<reportElement x="120" y="2" width="50" height="16" uuid="4a336320-9341-42dd-98c4-1cec2c2d6a15"/>
<textFieldExpression><![CDATA[$V{total}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="2" width="100" height="13" uuid="00887a5b-9421-402b-98b8-b041f08959f0">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<text><![CDATA[Total Items]]></text>
</staticText>
</band>
</summary>
Subreport:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1 -->
<!-- 2016-09-07T10:37:50 -->
<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="report" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="9014add6-11f0-4647-97ec-9b9f3f78afce">
<parameter name="item_id" class="java.lang.String" isForPrompting="false"/>
<queryString language="SQL">
<![CDATA[select b.item_id,
b.order_dt,
cpnv.item_desc,
cpnv.pull_dt,
b.ship_dt,
location = (select bjc.location_cd
from warehouse_location bjc
where bjc.item = b.item_id
and bjc.location_start_dt =
(select max(location_start_dt)
from warehouse_location
where item_id = b.item_id))
from item_names cpnv
join items b
ON cpnv.sub_id = b.sub_id
where (ship_dt is null or ship_dt >= '1-24-16 22:00')
and b.item_id = $P{item_id}]]>
</queryString>
<field name="item_id" class="java.lang.String"/>
<field name="order_dt" class="java.sql.Timestamp"/>
<field name="item_desc" class="java.lang.String"/>
<field name="pull_dt" class="java.sql.Timestamp"/>
<field name="ship_dt" class="java.sql.Timestamp"/>
<field name="location" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="41" splitType="Stretch">
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="9" y="11" width="67" height="20" isPrintWhenDetailOverflows="true" uuid="12d147f8-532b-4ed5-a249-e03661099e4f">
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{item_id}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="89" y="11" width="78" height="20" isPrintWhenDetailOverflows="true" uuid="76ea3e37-9b7a-44e3-a1ae-5850072b90ef">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy hh:mm").format($F{order_dt})]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="168" y="11" width="156" height="20" isPrintWhenDetailOverflows="true" uuid="9ab7bd73-e633-4d51-8271-00c673750a38">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{item_desc}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="326" y="11" width="48" height="20" isPrintWhenDetailOverflows="true" uuid="b0ac4ef7-e951-4fb2-ab80-3b6dc3103764">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy").format($F{pull_dt})]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="380" y="11" width="69" height="20" isPrintWhenDetailOverflows="true" uuid="83cb0048-4b23-42a9-a48d-63501a9f242d">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("MM/dd/yy hh:mm").format($F{ship_dt})]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" evaluationTime="Band" isBlankWhenNull="false">
<reportElement x="479" y="11" width="54" height="20" isPrintWhenDetailOverflows="true" uuid="67a5bd0d-cd6d-4910-83d0-396fc36781d3">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textFieldExpression><![CDATA[$F{location}]]></textFieldExpression>
</textField>
</band>
</detail>
I changed some of the names of things for proprietary reasons. Hopefully they are consistent. If something doesn't jive it was probably lost in translation.
As noted the query works fine in the subreport. When i give it one of the item_ids from the procedure in the master report it displays all the fields correctly for that item. It just won't come through to the master report.

You could try to print the subreport parameter $P{item_id} in the title band of the subreport to check if the parameter passing works correctly.
Depending on the height of the main reports detail band, Maybe you have to remove the top and bottom margin of the subreport.

Related

Iterate Collection on jaspersoft

I have a report that is simple, it has a few string paramters that receive all the data that i need. The strings are like this "1;2;3", "bob;john;mary". And i just need to show the data in rows. And it is working on jaspersoft. BUT not on jasperserver, when i run the report on jaspersoft server, it doesnt show the data.
I use .split(";") on the strings and cast it to arraylist and use it as datasource for my subreports. It is ugly but works, at least on jaspersoft. But it just doesnt on jasperserver.
The data comes from a angular project, and is filled by the user. I dont have this data on the DB.
I think its a problem on the way im using the datasource on the subreports but im not sure. Im new to jaspersoft. If this is not the way i should be doing this, pls say so, any help is appreciated
Here is my report code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.13.0.final using JasperReports Library version 6.13.0-46ada4d1be8f3c5985fd0b6146f3ed44caed6f05 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="OcorrenciasBancarias" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8fbddf4a-554c-4f04-9941-b9e16c98b10d">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="RK ERP Devel"/>
<property name="ireport.jasperserver.url" value="http://192.168.0.205:11001/jasperserver/"/>
<property name="ireport.jasperserver.user" value="jasperadmin"/>
<property name="ireport.jasperserver.report.resource" value="/reports/telas/quitacao_multiplas_contas/arquivo_retorno/ocorrenciasBancarias_files/main_jrxml"/>
<property name="ireport.jasperserver.reportUnit" value="/reports/telas/quitacao_multiplas_contas/arquivo_retorno/ocorrenciasBancarias"/>
<parameter name="CLIENTE" class="java.lang.String"/>
<parameter name="DOCUMENTO" class="java.lang.String"/>
<parameter name="NOSSONUMERO" class="java.lang.String"/>
<parameter name="VALOR" class="java.lang.String"/>
<parameter name="VENCIMENTO" class="java.lang.String"/>
<parameter name="OCORRENCIA" class="java.lang.String"/>
<parameter name="CLIENTELIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{CLIENTE}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="DOCUMENTOLIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{DOCUMENTO}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="NOSSONUMEROLIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{NOSSONUMERO}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="VALORLIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{VALOR}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="VENCIMENTOLIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{VENCIMENTO}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="OCORRENCIALIST" class="java.util.List">
<defaultValueExpression><![CDATA[Arrays.asList($P{OCORRENCIA}.split(";"))]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[select 1]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="40" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField pattern="dd/MM/yyyy">
<reportElement positionType="Float" x="379" y="0" width="80" height="20" forecolor="#27272F" uuid="a29fce94-a139-4d14-b782-9fe95ed43793">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField pattern="HH:mm">
<reportElement positionType="Float" x="432" y="0" width="50" height="20" forecolor="#27272F" uuid="22d51de7-fdb2-4681-a3d4-bc3ba4a4cc65">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<frame>
<reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="20" width="554" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="58d13352-4653-4587-827c-ea222229bbbe">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<printWhenExpression><![CDATA[new Boolean($V{PAGE_NUMBER} == 1)]]></printWhenExpression>
</reportElement>
<frame>
<reportElement positionType="Float" mode="Opaque" x="0" y="0" width="554" height="20" backcolor="#D9D9D9" uuid="7199097a-7296-410a-91f4-250495caab85">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<box leftPadding="1" bottomPadding="1" rightPadding="1">
<pen lineColor="#9FEDE5"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<staticText>
<reportElement positionType="Float" x="0" y="0" width="552" height="20" forecolor="#27272F" uuid="592cfe50-8cc4-473d-bac5-93c67922aedd">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<text><![CDATA[INFO FROM PARAMETERS]]></text>
</staticText>
</frame>
</frame>
<textField evaluationTime="Master">
<reportElement positionType="Float" x="442" y="0" width="112" height="20" forecolor="#27272F" uuid="921629e5-89b3-4d65-886d-fe20c21fa84b">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<font size="8"/>
</textElement>
<textFieldExpression><![CDATA["Página "+$V{MASTER_CURRENT_PAGE}+" de "+$V{MASTER_TOTAL_PAGES}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="14" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<line>
<reportElement x="0" y="13" width="555" height="1" forecolor="#595959" uuid="34831667-1d80-4cae-a91d-d6651c1cf3f4">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
<staticText>
<reportElement x="0" y="0" width="32" height="14" forecolor="#27272F" uuid="549ff20c-f7e6-46b8-b431-d361f478c4a5">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="4a6727e1-e6e7-4a70-8291-1a81b0a10118"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Cliente]]></text>
</staticText>
<staticText>
<reportElement x="130" y="0" width="60" height="14" forecolor="#27272F" uuid="835a1ff7-8ed8-4a88-b5f1-00cd6677957c">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="88aaba7a-4029-4a82-b1c2-ee8e93b1feb2"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Documento]]></text>
</staticText>
<staticText>
<reportElement x="200" y="0" width="70" height="14" forecolor="#27272F" uuid="dd5bfaf9-d080-4499-86f2-a7e0e4d3b492">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="5c2a2b79-9bac-4851-b7b3-c7642b0976ad"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Nosso Número]]></text>
</staticText>
<staticText>
<reportElement x="280" y="0" width="70" height="14" forecolor="#27272F" uuid="33fb80ff-5f98-4c6f-ae62-1695b0b08490">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="d4028cee-3416-4e73-8c8d-56b544671f27"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Valor]]></text>
</staticText>
<staticText>
<reportElement x="350" y="0" width="60" height="14" forecolor="#27272F" uuid="056f347b-d9a2-49ee-8674-8d31e9b07ea8">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8e8f8fed-a90c-4c5b-b2cc-d0ad1c49dc1a"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Vencimento]]></text>
</staticText>
<staticText>
<reportElement x="420" y="0" width="134" height="14" forecolor="#27272F" uuid="af29b7ba-2bc2-45be-a78a-f70bda792540">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="8e8f8fed-a90c-4c5b-b2cc-d0ad1c49dc1a"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="8" isBold="true"/>
</textElement>
<text><![CDATA[Ocorrência]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="30" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<subreport>
<reportElement x="0" y="0" width="130" height="30" uuid="914c099d-14bb-48a7-a696-73973de7093b">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{CLIENTELIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="130" y="0" width="70" height="30" uuid="924b44a1-81c6-4634-929d-e0ece1e11e2a">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{DOCUMENTOLIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT_VALOR.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="200" y="0" width="80" height="30" uuid="c957a547-8e5f-4985-83fd-cc7eebbe8568"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{NOSSONUMEROLIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT_NUMERO.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="280" y="0" width="70" height="30" uuid="735a18c3-59ff-425f-9752-4a54a29b7ccf">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{VALORLIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT_VALOR.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="350" y="0" width="70" height="30" uuid="417264e1-2694-462b-8cdc-a2768c3ef18c"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{VENCIMENTOLIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT_VALOR.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="420" y="0" width="135" height="30" uuid="5b686650-452c-4286-8513-163fa164f3ce">
<property name="com.jaspersoft.studio.unit.y" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{OCORRENCIALIST})]]></dataSourceExpression>
<subreportExpression><![CDATA["SUBREPORT_OCORRENCIA.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
Similar to what you have already done. But uses a single subreport.
$P{numbers}: 1;2;3
$P{names}: a;b;c
$P{numbersList}: Arrays.asList($P{numbers}.split(";"))
$P{namesList}: Arrays.asList($P{names}.split(";"))
$P{recordsList}: java.util.stream.IntStream.range(0, $P{numbersList}.size()).mapToObj( i -> new String[]{(String)$P{numbersList}.get(i), (String)$P{namesList}.get(i)} ).collect(java.util.stream.Collectors.toList())
The above code takes de 1st element of each list and puts in a single array. Then, takes de 2nd element of each list and so on. In the end you have this:
List[ [1, a], [2, b], [3, c] ]
When calling the subreport, you pass this datasource:
new net.sf.jasperreports.engine.data.ListOfArrayDataSource(
$P{recordsList},
new String[]{"number", "name"}
)
Obviously, in the subreport you must have the fields number and name.
This worked for me in Jaspersoft Studio.
Main.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.14.0.final using JasperReports Library version 6.14.0-2ab0d8625be255bf609c78e1181801213e51db8f -->
<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="Main" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="acfc3351-2262-463e-ae8a-dd475abdd1bc">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="numbers" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["1;2;3;4;5;6"]]></defaultValueExpression>
</parameter>
<parameter name="names" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["a;b;c;d;e;f"]]></defaultValueExpression>
</parameter>
<parameter name="numbersList" class="java.util.List" nestedType="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[Arrays.asList($P{numbers}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="namesList" class="java.util.List" nestedType="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[Arrays.asList($P{names}.split(";"))]]></defaultValueExpression>
</parameter>
<parameter name="recordsList" class="java.util.List" isForPrompting="false">
<defaultValueExpression><![CDATA[java.util.stream.IntStream.range(0, $P{numbersList}.size()).mapToObj( i -> new String[]{(String)$P{numbersList}.get(i), (String)$P{namesList}.get(i)} ).collect(java.util.stream.Collectors.toList())]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="30">
<textField>
<reportElement x="0" y="0" width="278" height="30" uuid="3bde936c-9702-404e-9932-68d37a915600"/>
<textFieldExpression><![CDATA[$P{numbersList}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="0" width="277" height="30" uuid="213c86ad-069a-4bdd-9840-cb71559fa265"/>
<textFieldExpression><![CDATA[$P{namesList}]]></textFieldExpression>
</textField>
</band>
</title>
<detail>
<band height="30" splitType="Stretch">
<subreport>
<reportElement x="0" y="0" width="555" height="30" uuid="8049f4ff-e490-4a1c-8c85-71be6335ba69"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.ListOfArrayDataSource( $P{recordsList}, new String[]{"number", "name"} )]]></dataSourceExpression>
<subreportExpression><![CDATA["Sub.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
Sub.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.14.0.final using JasperReports Library version 6.14.0-2ab0d8625be255bf609c78e1181801213e51db8f -->
<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="Sub" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="f06a30d4-cc6b-4ca5-a42f-3dcf791be297">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="NO_DATA_ADAPTER"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="number" class="java.lang.String"/>
<field name="name" class="java.lang.String"/>
<columnHeader>
<band height="30">
<staticText>
<reportElement x="0" y="0" width="278" height="30" uuid="3705eb7a-891e-4118-bcad-abae96e78171">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="4faf3089-5386-4350-9b8c-6f2f3eac41f7"/>
</reportElement>
<text><![CDATA[number]]></text>
</staticText>
<staticText>
<reportElement x="278" y="0" width="277" height="30" uuid="e194e190-bf9a-4f01-8aef-c2799a240199">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="cf256fba-83b6-4575-9cc7-487a63cfb77b"/>
</reportElement>
<text><![CDATA[name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="30" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="278" height="30" uuid="572c825e-3188-4b27-95e1-b24ac2009d6a">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="4faf3089-5386-4350-9b8c-6f2f3eac41f7"/>
</reportElement>
<textFieldExpression><![CDATA[$F{number}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="0" width="277" height="30" uuid="f1662cf8-13a8-4d5d-b55a-0901b2aabec3">
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="cf256fba-83b6-4575-9cc7-487a63cfb77b"/>
</reportElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

How to display each group of items on a new sheet in JasperReports?

I have a simple Spring-based web application for reporting about measurement tools. I'm using the following JRXML pattern (generated by TIBCO Jaspersoft Studio), let's say report_3.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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="polviz" class="java.lang.String"/>
<field name="polzex" class="java.lang.String"/>
<field name="polnaim" class="java.lang.String"/>
<field name="tip" class="java.lang.String"/>
<field name="klt" class="java.lang.Double"/>
<field name="pred" class="java.lang.String"/>
<field name="zavn" class="java.lang.String"/>
<field name="npasp" class="java.lang.Integer"/>
<field name="pp" class="java.lang.Integer"/>
<field name="n" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="84">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<staticText>
<reportElement x="410" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[УТВЕРЖДАЮ]]></text>
</staticText>
<staticText>
<reportElement x="410" y="14" width="100" height="20" />
<text><![CDATA[Главный метролог]]></text>
</staticText>
<line>
<reportElement x="410" y="39" width="120" height="1" />
</line>
<staticText>
<reportElement x="410" y="39" width="140" height="30" />
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[(подпись, расшифровка подписи, дата)]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="85" splitType="Stretch">
<staticText>
<reportElement positionType="FixRelativeToBottom" x="-2" y="0" width="559" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman"/>
</textElement>
<text><![CDATA[Общая ведомость средств измерений по цехам]]></text>
</staticText>
<line>
<reportElement x="0" y="83" width="554" height="1" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="0" y="66" width="554" height="16" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polviz}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="52" width="552" height="14" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isItalic="false"/>
</textElement>
<text><![CDATA[/ N - не проверено, R - ремонт, К - консервация /]]></text>
</staticText>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="1" y="30" width="552" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polzex}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="34" splitType="Stretch">
<staticText>
<reportElement x="1" y="1" width="110" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Наим. средства изм.]]></text>
</staticText>
<staticText>
<reportElement x="110" y="1" width="50" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Тип]]></text>
</staticText>
<staticText>
<reportElement x="160" y="1" width="68" height="30" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Предел изм.]]></text>
</staticText>
<staticText>
<reportElement x="280" y="1" width="78" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Зав. ном.]]></text>
</staticText>
<line>
<reportElement x="0" y="32" width="554" height="1" />
</line>
<line>
<reportElement x="0" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="109" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="159" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="228" y="-2" width="1" height="34" />
</line>
<line>
<reportElement x="359" y="-2" width="1" height="34" />
</line>
<staticText>
<reportElement x="360" y="1" width="74" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Ном. пасп.]]></text>
</staticText>
<line>
<reportElement x="434" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="436" y="0" width="54" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Периодич.]]></text>
</staticText>
<line>
<reportElement x="490" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="490" y="0" width="62" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Неп,Рем,Конс]]></text>
</staticText>
<line>
<reportElement x="554" y="-1" width="1" height="33" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="230" y="1" width="46" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Кл.т.]]></text>
</staticText>
<line>
<reportElement x="277" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="33">
<line>
<reportElement x="1" y="19" width="553" height="1" forecolor="#E5E5E5" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement x="2" y="1" width="108" height="18" />
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{polnaim}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="111" y="1" width="50" height="18" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{tip}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="161" y="1" width="68" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pred}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="1" width="48" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{klt}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="1" width="82" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zavn}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="360" y="1" width="76" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{npasp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="1" width="56" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="492" y="1" width="62" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{n}]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
Part of JasperReportsController controller:
...
#Controller
#RequestMapping("/jasper-reports/")
public class JasperReportsController {
#Autowired(required = true)
private MetrologServices metrologServices;
#Autowired
private ApplicationContext appContext;
#RequestMapping(method = RequestMethod.GET, value = "report_3")
public ModelAndView generateThirdPdfReport(ModelAndView modelAndView) {
JasperReportsPdfView jrPdfView = new JasperReportsPdfView();
List<ReportDTO> records = findInventoryReportData();
Map<String, Object> map = new HashMap<String, Object>();
map.put("records", records);
jrPdfView.setUrl("classpath:report_3.jrxml");
jrPdfView.setReportDataKey("records");
jrPdfView.setApplicationContext(appContext);
modelAndView = new ModelAndView(jrPdfView, map);
return modelAndView;
}
private List<ReportDTO> findInventoryReportData() {
List<ReportDTO> result = metrologServices.loadInventoryData();
return result;
}
...
}
Somewhere in the view I call the controller:
$("#btn-print").attr("href", "${home}/metrolog/jasper-reports/report_3");
As a result I get the following report:
I want to start the list of measurement tools for each department with a new page. For example, part of the measuring tools belongs to department 1, another part belongs to department 2, etc.
I'd advise the following documentation: Chapter 14. View technologies, see section "14.7.4. Working with Sub-Reports":
JasperReports provides support for embedded sub-reports within your
master report files. There are a wide variety of mechanisms for
including sub-reports in your report files. The easiest way is to hard
code the report path and the SQL query for the sub report into your
design files. The drawback of this approach is obvious - the values
are hard-coded into your report files reducing reusability and making
it harder to modify and update report designs. To overcome this you
can configure sub-reports declaratively and you can include additional
data for these sub-reports directly from your controllers.
To control which sub-report files are included in a master report
using Spring, your report file must be configured to accept
sub-reports from an external source. To do this you declare a
parameter in your report file like so:
<parameter name="ProductsSubReport" class="net.sf.jasperreports.engine.JasperReport"/>
Then, you define your sub-report to use this sub-report parameter:
<subreport>
<reportElement isPrintRepeatedValues="false" x="5" y="25" width="325"
height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/>
<subreportParameter name="City">
<subreportParameterExpression><![CDATA[$F{city}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{ProductsSubReport}]]></subreportExpression>
</subreport>
This defines a master report file that expects the sub-report to be
passed in as an instance of
net.sf.jasperreports.engine.JasperReports under the parameter
ProductsSubReport. When configuring your Jasper view class, you can
instruct Spring to load a report file and pass into the JasperReports
engine as a sub-report using the subReportUrls property:
<property name="subReportUrls">
<map>
<entry key="ProductsSubReport" value="/WEB-INF/reports/subReportChild.jrxml"/>
</map>
</property>
Here, the key of the Map corresponds to the name of the sub-report
parameter in th report design file, and the entry is the URL of the
report file. Spring will load this report file, compiling it if
necessary, and will pass into the JasperReports engine under the given
key.
Hence, the master report file can be represented as follows:
report_3.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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<parameter name="Kpp9SubReport" class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="Kpp9SubReportData" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="..." class="net.sf.jasperreports.engine.JasperReport"/>
<parameter name="..." class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
...
etc
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="84">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<staticText>
<reportElement x="410" y="0" width="100" height="20" isPrintWhenDetailOverflows="true"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[УТВЕРЖДАЮ]]></text>
</staticText>
<staticText>
<reportElement x="410" y="14" width="100" height="20" />
<text><![CDATA[Главный метролог]]></text>
</staticText>
<line>
<reportElement x="410" y="39" width="120" height="1" />
</line>
<staticText>
<reportElement x="410" y="39" width="140" height="30" />
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[(подпись, расшифровка подписи, дата)]]></text>
</staticText>
</band>
</title>
<detail>
<band height="500">
<subreport>
<reportElement isPrintRepeatedValues="false" x="-10" y="0" width="325" height="1" isRemoveLineWhenBlank="false" backcolor="#ffcc99"/>
<dataSourceExpression><![CDATA[$P{DepartmentKpp9SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{DepartmentKpp9SubReport}]]></subreportExpression>
</subreport>
<break type="Page">
<reportElement x="-10" y="1" width="325" height="10" key="element-1"/>
</break>
</band>
<band height="500">
<subreport>
<reportElement isPrintRepeatedValues="false" x="-10" y="2" width="325" height="1" isRemoveLineWhenBlank="false" backcolor="#ffcc99"/>
<dataSourceExpression><![CDATA[$P{Department8SubReportData}]]></dataSourceExpression>
<subreportExpression class="net.sf.jasperreports.engine.JasperReport">
<![CDATA[$P{Department8SubReport}]]></subreportExpression>
</subreport>
<break type="Page">
<reportElement x="-10" y="3" width="325" height="1" key="element-2"/>
</break>
</band>
<band height="500">
...
</band>
...
etc
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
The sub-report report_4.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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="Default" isDefault="true" pdfFontName="ARIAL.TTF" pdfEncoding="Cp1251"/>
<field name="polviz" class="java.lang.String"/>
<field name="polzex" class="java.lang.String"/>
<field name="polnaim" class="java.lang.String"/>
<field name="tip" class="java.lang.String"/>
<field name="klt" class="java.lang.Double"/>
<field name="pred" class="java.lang.String"/>
<field name="zavn" class="java.lang.String"/>
<field name="npasp" class="java.lang.Integer"/>
<field name="pp" class="java.lang.Integer"/>
<field name="n" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="85" splitType="Stretch">
<staticText>
<reportElement positionType="FixRelativeToBottom" x="-2" y="0" width="559" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman"/>
</textElement>
<text><![CDATA[Общая ведомость средств измерений по цехам]]></text>
</staticText>
<line>
<reportElement x="0" y="83" width="554" height="1" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="0" y="66" width="554" height="16" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polviz}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="1" y="52" width="552" height="14" />
<textElement textAlignment="Right" verticalAlignment="Middle">
<font isItalic="false"/>
</textElement>
<text><![CDATA[/ N - не проверено, R - ремонт, К - консервация /]]></text>
</staticText>
<textField>
<reportElement stretchType="RelativeToTallestObject" x="1" y="30" width="552" height="20" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{polzex}]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="34" splitType="Stretch">
<staticText>
<reportElement x="1" y="1" width="110" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Наим. средства изм.]]></text>
</staticText>
<staticText>
<reportElement x="110" y="1" width="50" height="30" />
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Тип]]></text>
</staticText>
<staticText>
<reportElement x="160" y="1" width="68" height="30" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Предел изм.]]></text>
</staticText>
<staticText>
<reportElement x="280" y="1" width="78" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Зав. ном.]]></text>
</staticText>
<line>
<reportElement x="0" y="32" width="554" height="1" />
</line>
<line>
<reportElement x="0" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="109" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="159" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<line>
<reportElement x="228" y="-2" width="1" height="34" />
</line>
<line>
<reportElement x="359" y="-2" width="1" height="34" />
</line>
<staticText>
<reportElement x="360" y="1" width="74" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Ном. пасп.]]></text>
</staticText>
<line>
<reportElement x="434" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="436" y="0" width="54" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Периодич.]]></text>
</staticText>
<line>
<reportElement x="490" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="490" y="0" width="62" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Неп,Рем,Конс]]></text>
</staticText>
<line>
<reportElement x="554" y="-1" width="1" height="33" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
<staticText>
<reportElement x="230" y="1" width="46" height="30" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[Кл.т.]]></text>
</staticText>
<line>
<reportElement x="277" y="-2" width="1" height="34" >
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="33">
<line>
<reportElement x="1" y="19" width="553" height="1" forecolor="#E5E5E5" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
</line>
<textField>
<reportElement x="2" y="1" width="108" height="18" />
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{polnaim}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="111" y="1" width="50" height="18" >
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{tip}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="161" y="1" width="68" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pred}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="1" width="48" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{klt}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="278" y="1" width="82" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{zavn}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="360" y="1" width="76" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{npasp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="436" y="1" width="56" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{pp}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="492" y="1" width="62" height="18" >
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{n}]]></textFieldExpression>
</textField>
</band>
</detail>
<lastPageFooter>
<band height="21"/>
</lastPageFooter>
</jasperReport>
Part of JasperReportsController controller(we consider only the case of one department, the other sub-reports can be obtained similarly using the same templates report_3.jrxml and report_4.jrxml):
...
#Controller
#RequestMapping("/jasper-reports/")
public class JasperReportsController {
#Autowired(required = true)
private MetrologServices metrologServices;
#Autowired
private ApplicationContext appContext;
#RequestMapping(method = RequestMethod.GET, value="report_3")
public ModelAndView generateThirdPdfReport(ModelAndView modelAndView) {
JasperReportsPdfView jrPdfView = new JasperReportsPdfView();
List<ReportDTO> records = findInventoryReportData();
Map<String, Object> map = new HashMap<>();
map.put("records", records);
Properties subReports = new Properties();
subReports.put("Kpp9SubReport", "classpath:report_4.jrxml");
List<ReportDTO> kpp9SubReportRecords = new ArrayList<>();
records.forEach(record -> {
if(record.getPolzex().equalsIgnoreCase("КПП 9")) {
kpp9SubReportRecords.add(record);
}
});
JRDataSource kpp9SubReportDataSource =
new JRBeanCollectionDataSource(kpp9SubReportRecords);
parameterMap.put("Kpp9SubReportData", kpp9SubReportDataSource);
jrPdfView.setSubReportUrls(subReports);
jrPdfView.setSubReportDataKeys("Kpp9SubReportData");
jrPdfView.setUrl("classpath:report_3.jrxml");
jrPdfView.setReportDataKey("records");
jrPdfView.setApplicationContext(appContext);
modelAndView = new ModelAndView(jrPdfView, map);
return modelAndView;
}
private List<ReportDTO> findInventoryReportData() {
List<ReportDTO> result = metrologServices.loadInventoryData();
return result;
}
...
}
As a result, we getting such a report, as required(in the department there are only five measuring instruments):

Field not found in report

I try to create a JasperReport's report with charts but getting error. I used table in the report and pie chart. Where I did wrong ?
I want to use same fields for reports and charts but I don't know how to use in both components.
Error:
Fields not found : campaignName
Fields not found : numTransmissions
<?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="template_Table" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoPages" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<subDataset name="Dataset1">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<field name="campaignName" class="java.lang.String"/>
<field name="numTransmissions" class="java.lang.Integer"/>
<group name="Group1">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/15)]]></groupExpression>
</group>
<group name="Group2">
<groupExpression><![CDATA[(int)($V{REPORT_COUNT}/5)]]></groupExpression>
</group>
<detail>
<band height="449" splitType="Stretch">
<componentElement>
<reportElement stretchType="RelativeToTallestObject" mode="Transparent" x="0" y="0" width="800" height="199" forecolor="#FFFFFF" backcolor="#424242">
</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"/>
<jr:column width="52">
<jr:tableHeader height="70">
<staticText>
<reportElement x="0" y="0" width="52" height="70"/>
<box leftPadding="3"/>
<textElement textAlignment="Left" verticalAlignment="Middle" markup="html">
<font fontName="Verdana" size="9"/>
</textElement>
<text><![CDATA[Campaign Name]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="50">
<textField>
<reportElement x="0" y="0" width="52" height="50"/>
<box leftPadding="6"/>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Verdana"/>
</textElement>
<textFieldExpression><![CDATA[$F{campaignName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="53">
<jr:tableHeader height="70">
<staticText>
<reportElement x="0" y="0" width="53" height="70"/>
<box leftPadding="3"/>
<textElement textAlignment="Left" verticalAlignment="Middle" markup="html">
<font fontName="Verdana" size="9"/>
</textElement>
<text><![CDATA[Email Transmissions]]></text>
</staticText>
</jr:tableHeader>
<jr:detailCell height="50">
<textField>
<reportElement x="0" y="0" width="53" height="50"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{numTransmissions}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<summary>
<band height="400" splitType="Stretch">
<pieChart>
<chart evaluationTime="Report">
<reportElement x="135" y="0" width="270" height="300"/>
<chartTitle>
<titleExpression><![CDATA["My First JR Pie Chart"]]></titleExpression>
</chartTitle>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{campaignName}]]></keyExpression>
<valueExpression><![CDATA[$F{numTransmissions}]]></valueExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
</band>
</summary>
</jasperReport>

Understanding Jrxml with a custom datasource

I am creating a Jasper report using a custom datasource.
I am using iReport to create the report.
Although I can see report working following various articles on web, I fail to understand how the generated Jrxml knows that it is supposed to fetch data from a custom JRDatasource ?
I can't see Jrxml pointing to my custom datasource class anywhere ???
Can someone provide more information ?
Here is the generated 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="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="a19f56bb-4764-4dad-8177-9a410a0cb69d">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="productCode" class="java.lang.String"/>
<field name="stockLevelStatus" class="java.lang.String">
<fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="125" splitType="Stretch">
<textField>
<reportElement x="10" y="60" width="100" height="30" uuid="53ec360c-996a-48eb-9777-efbb9d5fa3d7"/>
<textFieldExpression><![CDATA[$F{productCode}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="10" y="0" width="100" height="30" uuid="dc8fcc8f-6294-4d5b-97de-4b68d2e6bb8b"/>
<text><![CDATA[productCode]]></text>
</staticText>
<textField>
<reportElement x="140" y="60" width="100" height="30" uuid="5219cffe-1786-4bd8-a8af-83eebda483cf"/>
<textFieldExpression><![CDATA[$F{stockLevelStatus}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="140" y="0" width="100" height="30" uuid="27edec96-50c6-4de0-830a-9593a0da7c17"/>
<text><![CDATA[stockLevelStatus]]></text>
</staticText>
</band>
</detail>
</jasperReport>
Can someone share Jrxml with custom datasource ?
Finally after a lot of R&D, I am able to solve the problem.
Here is the ".jrxml" file which allows you to plot a table in a Jasper report where table's data comes from a custom datasource.
You can find quite a few articles on web explaining how to write a custom datasource but none of them provides an example of how to use a custom datasource in a 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="custom" language="groovy" pageWidth="595" pageHeight="420" whenNoDataType="BlankPage" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="de.hybris.platform.cockpit.reports.scriptlets.DateTimeScriptlet" resourceBundle="localization/jasperreports">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<subDataset name="custome_datasource">
<queryString>
<![CDATA[select 1 from DUAL]]>
</queryString>
<field name="productCode" class="java.lang.String"/>
<field name="stockLevelStatus" class="java.lang.String">
<fieldDescription><![CDATA[stockLevelStatus]]></fieldDescription>
</field>
</subDataset>
<queryString>
<![CDATA[select 1 from DUAL]]>
</queryString>
<title>
<band height="80" splitType="Stretch">
<staticText>
<reportElement x="10" y="0" width="500" height="30"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="16" isBold="true"/>
</textElement>
<text><![CDATA[Stock Level Status Report]]></text>
</staticText>
</band>
</title>
<detail>
<band height="340" splitType="Stretch">
<componentElement>
<reportElement key="table" x="0" y="0" width="555" height="238"/>
<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="custome_datasource">
<dataSourceExpression><![CDATA[new my.dataproviders.StockLevelDataProvider()]]></dataSourceExpression>
</datasetRun>
<jr:column width="130">
<jr:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<text><![CDATA[ProductCode]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="10" width="90" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{productCode}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130">
<jr:columnHeader height="30" rowSpan="1">
<staticText>
<reportElement x="0" y="0" width="92" height="25" backcolor="#99CCFF"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="true"/>
</textElement>
<text><![CDATA[StockLevel]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="30" rowSpan="1">
<textField>
<reportElement x="0" y="10" width="90" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="9" isBold="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{stockLevelStatus}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>

x axis value displayed in line chart

I have Line chart, in x axis i should display date in string format in full format, but i cant display when more no of values in x axis, for that i decided to display x axis values in vertical manner instead of horizontal , please suggest me. for ref attached image..
<?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="sampl1" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="431d18d3-722a-4aaf-8207-da8bb0ea2fdd">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="51"/>
<parameter name="whereClause" class="java.lang.String"/>
<parameter name="bankLogo" class="java.lang.String"/>
<parameter name="bankName" class="java.lang.String"/>
<parameter name="fromDate" class="java.util.Date">
<parameterDescription><![CDATA[]]></parameterDescription>
</parameter>
<parameter name="toDate" class="java.util.Date"/>
<parameter name="noData" class="java.lang.String"/>
<parameter name="userId" class="java.lang.String"/>
<queryString>
<![CDATA[select avg(jbase_user) as jbaseAvg,AVG(t24_user) as t24Avg,to_char(load_time, 'dd.Mon.yy HH24') as period
from tmc_system_summary group by (to_char(load_time, 'dd.Mon.yy HH24'))]]>
</queryString>
<field name="jbaseavg" class="java.math.BigDecimal"/>
<field name="t24avg" class="java.math.BigDecimal"/>
<field name="period" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="30" splitType="Stretch"/>
</title>
<pageHeader>
<band height="67" splitType="Stretch">
<staticText>
<reportElement x="300" y="22" width="235" height="15" uuid="164831c1-9eff-4cf2-8706-331d28fdf431"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="12" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ System Summary Report]]></text>
</staticText>
<image>
<reportElement x="12" y="3" width="161" height="30" uuid="513d2931-a2c7-4e54-bb86-188737502cae"/>
<imageExpression><![CDATA[$P{bankLogo}]]></imageExpression>
</image>
<textField pattern="dd/MM/yyyy">
<reportElement x="735" y="2" width="55" height="17" uuid="306ddad6-2b80-4abb-9893-859c59c8ede5"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="2" width="30" height="17" uuid="c6fdbff7-45a5-464e-bcbf-d550b174452f"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="Arial"/>
</textElement>
<text><![CDATA[Date:]]></text>
</staticText>
<staticText>
<reportElement x="20" y="40" width="58" height="14" uuid="5bd47ff1-6b81-428a-b7fd-50e777f70a22"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[From Date:]]></text>
</staticText>
<staticText>
<reportElement x="160" y="40" width="58" height="14" uuid="a7605d9e-c0d1-4a31-8230-c73db35766d4"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[To Date:]]></text>
</staticText>
<textField pattern="dd/MM/yyyy">
<reportElement x="80" y="40" width="70" height="14" uuid="faa13401-da98-4f06-ab43-5a1722d073f7"/>
<textFieldExpression><![CDATA[$P{fromDate} != null ? $P{fromDate} :" "]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="215" y="40" width="70" height="13" uuid="01fcdb71-820f-4ef1-9913-6ddcf36be2dc"/>
<textFieldExpression><![CDATA[$P{toDate} != null ? $P{toDate} : " "]]></textFieldExpression>
</textField>
<textField>
<reportElement x="300" y="2" width="235" height="17" uuid="7eec4f6f-5bfd-4bb0-8888-8cad8d9d84ad"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="14" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression><![CDATA[$P{bankName}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="700" y="22" width="30" height="15" uuid="08ba273e-733d-4652-9f7a-83a51f7d78ca"/>
<textElement textAlignment="Right"/>
<text><![CDATA[By:]]></text>
</staticText>
<textField>
<reportElement x="735" y="22" width="55" height="15" uuid="261308a5-7cef-42f8-8880-9d2c9cc5d5ae"/>
<textFieldExpression><![CDATA[$P{userId}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="54" width="802" height="1" uuid="e17b6ea4-40fd-40ad-861f-a300f926d0e4"/>
</line>
</band>
</pageHeader>
<columnHeader>
<band splitType="Stretch"/>
![enter image description here][1] </columnHeader>
<columnFooter>
<band height="17" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="546" y="1" width="70" height="19" uuid="eeafb0de-dddb-4c9a-8a1d-942b65bf0a7f"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Arial" size="10"/>
</textElement>
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="392" splitType="Stretch">
<lineChart>
<chart>
<reportElement x="12" y="18" width="779" height="355" uuid="f696d665..
By this you can display the x axis value in vertical ( topDown)
<categoryAxisFormat labelRotation="90.0">
it will work.