Wednesday 18 July 2018

Composite element example in Jaspersoft Reports

Hi,

Composite element allow to create a new element in the palette starting from one or more basic elements, and reuse them whenever you want in any report.

As shown in below image you can take basic elements like Text Field and Ellipse from palette. Right click on the selection of these two to create composite element and give required details(name, description and an icon with position to keep it on the palette).

(NOTE : Click on image to get the best view of content placed)

(NOTE : Click on image to get the best view of content placed)


Composite element allows below actions(Edit, Export and Import)  in studio.

This way you can create a custom element in palette and use in a project if you have to re-use the code/design. i.e., this will give the flexibility of re-usability of design across reports. kinda a components based templates.

References: https://community.jaspersoft.com/wiki/composite-element

- Sadakar Pochampalli


JRXML:(Supports in 6.4.2 professional or later).
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.2.final using JasperReports Library version 6.4.1  -->
<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="CompositeElementExample" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ab08f6fe-e37c-42b7-8721-c46a41536ae3">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="133" splitType="Stretch">
<textField>
<reportElement x="138" y="40" width="100" height="30" uuid="0035655a-100c-4dac-a8b8-a91e6a916b0d"/>
<textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>
</textField>
<ellipse>
<reportElement x="240" y="10" width="100" height="79" uuid="3207973b-e49e-43cc-9611-6ed03ce5b3cd"/>
</ellipse>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch"/>
</columnHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<columnFooter>
<band height="45" splitType="Stretch"/>
</columnFooter>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

No comments:

Post a Comment