bamabi45320 Posted January 15, 2016 Share Posted January 15, 2016 Hi,I'm working on Jaspersoft Studio and I want to know how can I print multiple reports using one jrxml and an XML file.For example, I have this XML: <?xml version="1.0" encoding="UTF-8"?><items><item><name>Torres</name><certificate><certificate_name>BAC</certificate_name><certificate_year>2000</certificate_year></certificate><certificate><certificate_name>BTS</certificate_name><certificate_year>2012</certificate_year></certificate> </item><item><name>Crane</name><certificate><certificate_name>CAP</certificate_name><certificate_year>2012</certificate_year></certificate> <certificate><certificate_name>BEP</certificate_name><certificate_year>2013</certificate_year></certificate> </item></items> And this report :[/code]<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 --><!-- 2016-01-15T11:00:36 --><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" uuid="5c659b5e-0aa2-418b-ba5d-6ffd6f69c888"><property name="net.sf.jasperreports.data.adapter" value="XmlAdapter.xml"/><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 1_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 2_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 2_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 2_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="DataSetTable" uuid="8b03db47-9f29-4097-880b-0605d2e14cb3"><property name="com.jaspersoft.studio.data.defaultdataadapter" value="XmlAdapter.xml"/><queryString language="XPath"><![CDATA[/items/item/certificate]]></queryString><field name="certificate_year" class="java.lang.String"><fieldDescription><![CDATA[certificate_year]]></fieldDescription></field><field name="certificate_name" class="java.lang.String"><fieldDescription><![CDATA[certificate_name]]></fieldDescription></field></subDataset><queryString language="XPath"><![CDATA[/items/item]]></queryString><field name="name" class="java.lang.String"><fieldDescription><![CDATA[name]]></fieldDescription></field><title><band height="103" splitType="Stretch"><staticText><reportElement x="0" y="0" width="555" height="79" uuid="ac9f0b4b-8168-42ab-b980-d2d3a2bc3059"/><textElement textAlignment="Center" verticalAlignment="Middle"><font size="42"/></textElement><text><![CDATA[Personnal report]]></text></staticText></band></title><detail><band height="312"><textField><reportElement x="110" y="1" width="100" height="30" uuid="4c72a837-8fc3-4255-b4f0-b0fb8548e57d"/><textFieldExpression><![CDATA[$F{name}]]></textFieldExpression></textField><staticText><reportElement x="10" y="1" width="100" height="30" uuid="286d8d1b-ee2e-412e-84bf-cf1d2483aaa3"/><text><![CDATA[name]]></text></staticText><componentElement><reportElement x="10" y="31" width="200" height="119" uuid="c9befb07-30a9-425b-b873-14e1c2f36e8a"><property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/></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="DataSetTable" uuid="f48ca1cf-6217-4734-9c45-4464993f3d7a"><dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/item/certificate")]]></dataSourceExpression></datasetRun><jr:column width="100" uuid="d1ffa2e8-1c9c-4d5d-81f2-3eff4ef110b0"><property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne1"/><jr:columnHeader style="Table 2_CH" height="30"><staticText><reportElement x="0" y="0" width="100" height="30" uuid="9a8fe1a3-6b23-418a-bc8c-b7db78fd1db8"/><text><![CDATA[certificate_name]]></text></staticText></jr:columnHeader><jr:detailCell style="Table 2_TD" height="30"><textField><reportElement x="0" y="0" width="100" height="30" uuid="f2a86c0d-5b1d-4195-ac79-3a18d026bdad"/><textFieldExpression><![CDATA[$F{certificate_name}]]></textFieldExpression></textField></jr:detailCell></jr:column><jr:column width="100" uuid="06bd8366-bf8c-4f76-a302-d1dad72a4f04"><property name="com.jaspersoft.studio.components.table.model.column.name" value="Colonne2"/><jr:columnHeader style="Table 2_CH" height="30"><staticText><reportElement x="0" y="0" width="100" height="30" uuid="9dcccd71-3a9a-410e-b8c5-94755c77ff54"/><text><![CDATA[certificate_year]]></text></staticText></jr:columnHeader><jr:detailCell style="Table 2_TD" height="30"><textField><reportElement x="0" y="0" width="100" height="30" uuid="cd49394e-161d-48b5-b99a-5042768f3cbe"/><textFieldExpression><![CDATA[$F{certificate_year}]]></textFieldExpression></textField></jr:detailCell></jr:column></jr:table></componentElement></band></detail></jasperReport> This return a report with the description of the two items.But I want to create a new report (with the title, etc) for each "item" of my XML file. Regards,Alban Link to comment Share on other sites More sharing options...
zh3ntil Posted January 15, 2016 Share Posted January 15, 2016 create a group from outline based on name field. Click group band and go to group band propertes. check the 'new page' under Group Band Properties.After that, go to report properties and check the properies as you want for example 'title on a new page' Link to comment Share on other sites More sharing options...
bamabi45320 Posted January 15, 2016 Author Share Posted January 15, 2016 Thanks a lot, it works perfectly ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now