I have a field with values:
CM45024,CM45025,CM45026
I want to separate this into multiple items using subreport. My jrxml source is:
<field name="docIdNoGRN" class="java.lang.String">
<fieldDescription><![CDATA[docIdNoGRN]]></fieldDescription>
</field>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-53" x="311" y="1" width="88" height="15" uuid="2e040fd0-8fae-46e8-a845-fba421922992"/>
<textElement textAlignment="Center">
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[($F{docIdNoGRN} != null && $F{docIdNoGRN}.toString().length() > 0) ? $F{docIdNoGRN} : " "]]>
</textFieldExpression>
</textField>
The field can have 3 or more items as it depends on the data. Instead of having one item in the report:
Item No. Item ID.
1 CM45024,CM45025,CM45026
I want to show it like this:
Item No. Item ID.
1 CM45024
2 CM45025
3 CM45026
Im using TIBCO Jaspersoft® Studio Professional - Visual Designer for JasperReport 6.1.1.
This is how it can be achieved using subreport, assuming that your
$F{docIdNoGRN}
contains the String "CM45024,CM45025,CM45026"Generate the data source that will be passed to the subreport
As you can see I
split(",")
your fieldString
getting anArray
that is converted toList
and then passed in aJRBeanCollectionDataSource
example: (your_subreport.jrxml):
I have added the
$V{REPORT_COUNT}
to achieve the numbers (1,2,3) .The output will be
Note: You can also use the jr:table component to achieve this if you like to avoid generating a subreport (just define the table datasource as above)