Skip to content

SampleReportDesigns

mzuchowski edited this page Apr 2, 2015 · 1 revision

Introduction

Those samples are used as examples in tutorials. Original files can be found in examples

Liferay User Roles

  	<?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="liferay_roles" language="groovy" pageWidth="792" pageHeight="778"
		orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20"
		topMargin="20" bottomMargin="20">
		<property name="ireport.zoom" value="1.0" />
		<property name="ireport.x" value="0" />
		<property name="ireport.y" value="56" />
		<queryString>
			<![CDATA[select name as role, count(*) as users
	from role_ r left join users_roles ur on (r.roleid = ur.roleid)
	group by name]]>
		</queryString>
		<field name="ROLE" class="java.lang.String" />
		<field name="USERS" class="java.lang.Integer" />
		<group name="ROLE">
			<groupExpression><![CDATA[$F{ROLE}]]></groupExpression>
		</group>
		<background>
			<band splitType="Stretch" />
		</background>
		<title>
			<band height="421" splitType="Stretch">
				<bar3DChart>
					<chart evaluationTime="Report">
						<reportElement x="0" y="79" width="752" height="342" />
						<chartTitle />
						<chartSubtitle />
						<chartLegend />
					</chart>
					<categoryDataset>
						<categorySeries>
							<seriesExpression><![CDATA[$F{ROLE}]]></seriesExpression>
							<categoryExpression><![CDATA[""]]></categoryExpression>
							<valueExpression><![CDATA[$F{USERS}]]></valueExpression>
							<labelExpression><![CDATA[$F{ROLE}]]></labelExpression>
						</categorySeries>
					</categoryDataset>
					<bar3DPlot>
						<plot />
						<itemLabel />
						<categoryAxisLabelExpression><![CDATA["Role"]]></categoryAxisLabelExpression>
						<valueAxisLabelExpression><![CDATA["Number of users"]]></valueAxisLabelExpression>
					</bar3DPlot>
				</bar3DChart>
				<staticText>
					<reportElement x="0" y="0" width="752" height="79" />
					<textElement textAlignment="Center" verticalAlignment="Middle">
						<font fontName="FreeSans" size="24" />
					</textElement>
					<text><![CDATA[Liferay User Roles]]></text>
				</staticText>
			</band>
		</title>
		<pageHeader>
			<band splitType="Stretch" />
		</pageHeader>
		<columnHeader>
			<band height="61" splitType="Stretch">
				<staticText>
					<reportElement x="0" y="0" width="345" height="61"
						forecolor="#000000" />
					<textElement textAlignment="Left" verticalAlignment="Middle">
						<font fontName="SansSerif" size="22" isBold="true" />
					</textElement>
					<text><![CDATA[Role]]></text>
				</staticText>
				<staticText>
					<reportElement x="396" y="0" width="356" height="61"
						forecolor="#000000" />
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font fontName="SansSerif" size="22" isBold="true" />
					</textElement>
					<text><![CDATA[Number of Users]]></text>
				</staticText>
			</band>
		</columnHeader>
		<detail>
			<band height="25" splitType="Stretch">
				<textField>
					<reportElement x="0" y="0" width="345" height="25" />
					<textElement textAlignment="Left" verticalAlignment="Middle">
						<font size="18" />
					</textElement>
					<textFieldExpression><![CDATA[$F{ROLE}]]></textFieldExpression>
				</textField>
				<textField>
					<reportElement x="396" y="0" width="356" height="25" />
					<textElement textAlignment="Right" verticalAlignment="Middle">
						<font size="18" />
					</textElement>
					<textFieldExpression><![CDATA[$F{USERS}]]></textFieldExpression>
				</textField>
			</band>
		</detail>
		<columnFooter>
			<band splitType="Stretch" />
		</columnFooter>
		<pageFooter>
			<band splitType="Stretch" />
		</pageFooter>
		<summary>
			<band splitType="Stretch" />
		</summary>
	</jasperReport>


Role Users - Standard version


<?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="user_roles" language="groovy" pageWidth="360" pageHeight="620" columnWidth="320" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="role" class="java.lang.String">
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select u.firstname, u.lastname, u.emailaddress
from user_ u join users_roles ur on (u.userid = ur.userid) join role_ r on (ur.roleid = r.roleid)
where r.name = $P{role}]]>
	</queryString>
	<field name="FIRSTNAME" class="java.lang.String"/>
	<field name="LASTNAME" class="java.lang.String"/>
	<field name="EMAILADDRESS" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="40" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="320" height="40" forecolor="#000000"/>
				<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
					<font fontName="FreeSans" size="24"/>
				</textElement>
				<textFieldExpression><![CDATA["Users with role " + $P{role}]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="20" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="100" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[First name]]></text>
			</staticText>
			<staticText>
				<reportElement x="100" y="0" width="100" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[Last name]]></text>
			</staticText>
			<staticText>
				<reportElement x="200" y="0" width="120" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[Email]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="100" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{FIRSTNAME}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="100" y="0" width="100" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{LASTNAME}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="200" y="0" width="120" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{EMAILADDRESS}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>

Role Users - Extended for Aperte Reports

<?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="Role Users" language="groovy" pageWidth="360" pageHeight="620" columnWidth="320" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<parameter name="datasource" class="java.lang.String" isForPrompting="false">
		<parameterDescription><![CDATA[java:comp/env/jdbc/liferay]]></parameterDescription>
	</parameter>
	<parameter name="role" class="java.lang.String">
		<property name="input_type" value="select"/>
		<property name="dict_query" value="java:comp/env/jdbc/liferay; select name as key, name as value from role_"/>
		<property name="required" value="true"/>
		<property name="label" value="Role name"/>
		<defaultValueExpression><![CDATA[]]></defaultValueExpression>
	</parameter>
	<queryString>
		<![CDATA[select u.firstname, u.lastname, u.emailaddress
from user_ u join users_roles ur on (u.userid = ur.userid) join role_ r on (ur.roleid = r.roleid)
where r.name = $P{role}]]>
	</queryString>
	<field name="FIRSTNAME" class="java.lang.String"/>
	<field name="LASTNAME" class="java.lang.String"/>
	<field name="EMAILADDRESS" class="java.lang.String"/>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="40" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="320" height="40" forecolor="#000000"/>
				<textElement textAlignment="Center" verticalAlignment="Middle" markup="none">
					<font fontName="FreeSans" size="24"/>
				</textElement>
				<textFieldExpression><![CDATA["Users with role " + $P{role}]]></textFieldExpression>
			</textField>
		</band>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="20" splitType="Stretch">
			<staticText>
				<reportElement x="0" y="0" width="100" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[First name]]></text>
			</staticText>
			<staticText>
				<reportElement x="100" y="0" width="100" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[Last name]]></text>
			</staticText>
			<staticText>
				<reportElement x="200" y="0" width="120" height="20"/>
				<textElement>
					<font fontName="FreeSans" size="14"/>
				</textElement>
				<text><![CDATA[Email]]></text>
			</staticText>
		</band>
	</columnHeader>
	<detail>
		<band height="20" splitType="Stretch">
			<textField>
				<reportElement x="0" y="0" width="100" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{FIRSTNAME}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="100" y="0" width="100" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{LASTNAME}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement x="200" y="0" width="120" height="20"/>
				<textElement verticalAlignment="Middle"/>
				<textFieldExpression><![CDATA[$F{EMAILADDRESS}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band splitType="Stretch"/>
	</columnFooter>
	<pageFooter>
		<band splitType="Stretch"/>
	</pageFooter>
	<summary>
		<band splitType="Stretch"/>
	</summary>
</jasperReport>