Skip to content

Commit 5992805

Browse files
committed
prepare sample listing report, with grouping
1 parent 99199c9 commit 5992805

13 files changed

+513
-43
lines changed

examples/groups.jrxml

+286
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Created with Jaspersoft Studio version 6.18.1.final using JasperReports Library version 6.18.1-9d75d1969e774d4f179fb3be8401e98a0e6d1611 -->
3+
<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="groups" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="91b09141-a7ac-4a00-9867-4b7b8d085c5d">
4+
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="postgres"/>
5+
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
6+
<queryString>
7+
<![CDATA[select * from users]]>
8+
</queryString>
9+
<field name="created" class="java.sql.Timestamp">
10+
<property name="com.jaspersoft.studio.field.name" value="created"/>
11+
<property name="com.jaspersoft.studio.field.label" value="created"/>
12+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
13+
</field>
14+
<field name="updated" class="java.sql.Timestamp">
15+
<property name="com.jaspersoft.studio.field.name" value="updated"/>
16+
<property name="com.jaspersoft.studio.field.label" value="updated"/>
17+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
18+
</field>
19+
<field name="gender" class="java.lang.String">
20+
<property name="com.jaspersoft.studio.field.name" value="gender"/>
21+
<property name="com.jaspersoft.studio.field.label" value="gender"/>
22+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
23+
</field>
24+
<field name="user_id" class="java.lang.Long">
25+
<property name="com.jaspersoft.studio.field.name" value="user_id"/>
26+
<property name="com.jaspersoft.studio.field.label" value="user_id"/>
27+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
28+
</field>
29+
<field name="fullname" class="java.lang.String">
30+
<property name="com.jaspersoft.studio.field.name" value="fullname"/>
31+
<property name="com.jaspersoft.studio.field.label" value="fullname"/>
32+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
33+
</field>
34+
<field name="email" class="java.lang.String">
35+
<property name="com.jaspersoft.studio.field.name" value="email"/>
36+
<property name="com.jaspersoft.studio.field.label" value="email"/>
37+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
38+
</field>
39+
<field name="description" class="java.lang.String">
40+
<property name="com.jaspersoft.studio.field.name" value="description"/>
41+
<property name="com.jaspersoft.studio.field.label" value="description"/>
42+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
43+
</field>
44+
<field name="createdby" class="java.lang.Long">
45+
<property name="com.jaspersoft.studio.field.name" value="createdby"/>
46+
<property name="com.jaspersoft.studio.field.label" value="createdby"/>
47+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
48+
</field>
49+
<field name="updatedby" class="java.lang.Long">
50+
<property name="com.jaspersoft.studio.field.name" value="updatedby"/>
51+
<property name="com.jaspersoft.studio.field.label" value="updatedby"/>
52+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
53+
</field>
54+
<field name="country_code" class="java.lang.String">
55+
<property name="com.jaspersoft.studio.field.name" value="country_code"/>
56+
<property name="com.jaspersoft.studio.field.label" value="country_code"/>
57+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
58+
</field>
59+
<field name="groupname" class="java.lang.String">
60+
<property name="com.jaspersoft.studio.field.name" value="groupname"/>
61+
<property name="com.jaspersoft.studio.field.label" value="groupname"/>
62+
<property name="com.jaspersoft.studio.field.tree.path" value="users"/>
63+
</field>
64+
<sortField name="groupname"/>
65+
<sortField name="country_code"/>
66+
<sortField name="gender"/>
67+
<group name="grpuser" isStartNewPage="true">
68+
<groupExpression><![CDATA[$F{groupname}]]></groupExpression>
69+
<groupHeader>
70+
<band height="30">
71+
<textField>
72+
<reportElement x="2" y="0" width="550" height="30" forecolor="#1A9C03" uuid="421271d7-fef9-4fbe-9a1e-fc60b662ee1a">
73+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
74+
</reportElement>
75+
<textElement textAlignment="Left">
76+
<font size="16" isBold="false"/>
77+
</textElement>
78+
<textFieldExpression><![CDATA["Marital Status : " + $F{groupname}]]></textFieldExpression>
79+
</textField>
80+
</band>
81+
</groupHeader>
82+
<groupFooter>
83+
<band height="30">
84+
<textField>
85+
<reportElement x="2" y="0" width="550" height="30" forecolor="#1A9C03" uuid="e0a3c47e-dac5-46e2-bda3-c69e8a55fb1b">
86+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
87+
</reportElement>
88+
<textElement textAlignment="Left">
89+
<font size="16" isBold="false"/>
90+
</textElement>
91+
<textFieldExpression><![CDATA["End Marital Status :"+$F{groupname}]]></textFieldExpression>
92+
</textField>
93+
</band>
94+
</groupFooter>
95+
</group>
96+
<group name="grpcountry">
97+
<groupExpression><![CDATA[$F{country_code}]]></groupExpression>
98+
<groupHeader>
99+
<band height="50">
100+
<textField>
101+
<reportElement x="0" y="10" width="552" height="20" uuid="a356d7b6-439c-4629-a878-ddc21b31c9bd">
102+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
103+
</reportElement>
104+
<box>
105+
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
106+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
107+
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
108+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
109+
</box>
110+
<textElement>
111+
<font isBold="true"/>
112+
</textElement>
113+
<textFieldExpression><![CDATA["Country : "+$F{country_code}]]></textFieldExpression>
114+
</textField>
115+
<staticText>
116+
<reportElement x="40" y="30" width="190" height="20" uuid="3433740a-ce94-4109-8dd4-5da4e3e1da92">
117+
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="822ebb87-81e7-4cc2-be46-10456e30a3a3"/>
118+
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
119+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
120+
</reportElement>
121+
<box>
122+
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
123+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
124+
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
125+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
126+
</box>
127+
<text><![CDATA[Name]]></text>
128+
</staticText>
129+
<staticText>
130+
<reportElement x="230" y="30" width="150" height="20" uuid="068686d2-e16b-4cbe-bfa4-29a9db1e156d">
131+
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="ba26e3b8-c075-412f-abbb-4f2171104dfe"/>
132+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
133+
</reportElement>
134+
<box>
135+
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
136+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
137+
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
138+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
139+
</box>
140+
<text><![CDATA[Email]]></text>
141+
</staticText>
142+
<staticText>
143+
<reportElement x="370" y="30" width="182" height="20" uuid="dfa4f373-a360-4e2d-86fc-27568ffccd33">
144+
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="356200ae-03ce-4684-87dd-028cbf4fbe20"/>
145+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
146+
</reportElement>
147+
<box>
148+
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
149+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
150+
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
151+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
152+
</box>
153+
<text><![CDATA[Description]]></text>
154+
</staticText>
155+
<staticText>
156+
<reportElement x="0" y="30" width="41" height="20" uuid="d20e4134-3b37-4a5a-9530-124e578a9c15">
157+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
158+
</reportElement>
159+
<box>
160+
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
161+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
162+
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
163+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
164+
</box>
165+
<text><![CDATA[No]]></text>
166+
</staticText>
167+
</band>
168+
</groupHeader>
169+
<groupFooter>
170+
<band height="20">
171+
<textField>
172+
<reportElement x="0" y="0" width="552" height="20" uuid="cc95c9c3-24ba-4837-9f5d-f150fba9523b">
173+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
174+
</reportElement>
175+
<box>
176+
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
177+
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
178+
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
179+
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
180+
</box>
181+
<textElement>
182+
<font isBold="true"/>
183+
</textElement>
184+
<textFieldExpression><![CDATA["End Country : "+$F{country_code}]]></textFieldExpression>
185+
</textField>
186+
</band>
187+
</groupFooter>
188+
</group>
189+
<group name="grpgender">
190+
<groupExpression><![CDATA[$F{gender}]]></groupExpression>
191+
<groupHeader>
192+
<band height="20">
193+
<textField>
194+
<reportElement x="0" y="0" width="280" height="20" uuid="5795c8fc-30d2-4f32-b1e0-5149047bc5de">
195+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
196+
</reportElement>
197+
<textFieldExpression><![CDATA["Gender : "+$F{gender}]]></textFieldExpression>
198+
</textField>
199+
</band>
200+
</groupHeader>
201+
<groupFooter>
202+
<band height="20">
203+
<textField>
204+
<reportElement x="0" y="0" width="280" height="20" uuid="6123b982-c4ea-40d1-b085-c309edda4002">
205+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
206+
</reportElement>
207+
<textFieldExpression><![CDATA["End Gender : "+$F{gender}]]></textFieldExpression>
208+
</textField>
209+
</band>
210+
</groupFooter>
211+
</group>
212+
<background>
213+
<band splitType="Stretch"/>
214+
</background>
215+
<pageHeader>
216+
<band height="30" splitType="Stretch">
217+
<staticText>
218+
<reportElement x="0" y="0" width="552" height="30" uuid="f7b7693c-c66b-4c6a-98c8-868d824c7dbe"/>
219+
<box>
220+
<bottomPen lineWidth="1.0" lineColor="#7965DB"/>
221+
</box>
222+
<textElement textAlignment="Center">
223+
<font size="16" isBold="true"/>
224+
</textElement>
225+
<text><![CDATA[User Listing Report]]></text>
226+
</staticText>
227+
</band>
228+
</pageHeader>
229+
<detail>
230+
<band height="20" splitType="Stretch">
231+
<textField textAdjust="StretchHeight">
232+
<reportElement x="370" y="0" width="182" height="20" uuid="679c3cdd-d3d9-4fe5-9a41-bc6837c55797"/>
233+
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
234+
</textField>
235+
<textField>
236+
<reportElement x="40" y="0" width="190" height="20" uuid="f052cb03-851f-4ef5-be9f-d55440a9616a">
237+
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="822ebb87-81e7-4cc2-be46-10456e30a3a3"/>
238+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
239+
</reportElement>
240+
<textElement verticalAlignment="Middle"/>
241+
<textFieldExpression><![CDATA[$F{fullname}]]></textFieldExpression>
242+
</textField>
243+
<textField>
244+
<reportElement x="230" y="0" width="140" height="20" uuid="5f82adb1-5a25-4995-9247-e202b01fec47">
245+
<property name="com.jaspersoft.studio.spreadsheet.connectionID" value="ba26e3b8-c075-412f-abbb-4f2171104dfe"/>
246+
<property name="com.jaspersoft.studio.unit.height" value="px"/>
247+
</reportElement>
248+
<textElement verticalAlignment="Middle"/>
249+
<textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
250+
</textField>
251+
<textField>
252+
<reportElement x="0" y="0" width="41" height="20" uuid="13422f88-6c5c-4b6a-8b80-6995dbb8cb7d"/>
253+
<textElement verticalAlignment="Middle"/>
254+
<textFieldExpression><![CDATA[$V{grpgender_COUNT}]]></textFieldExpression>
255+
</textField>
256+
</band>
257+
</detail>
258+
<pageFooter>
259+
<band height="20" splitType="Stretch">
260+
<textField>
261+
<reportElement x="178" y="0" width="100" height="20" uuid="c42fbbae-2d5a-476c-bda0-2404726c7b30"/>
262+
<textElement textAlignment="Right">
263+
<font size="8"/>
264+
</textElement>
265+
<textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
266+
</textField>
267+
<textField evaluationTime="Report">
268+
<reportElement x="278" y="0" width="100" height="20" uuid="1a63794f-075a-4ede-9b92-76c6222ea0f5"/>
269+
<textElement textAlignment="Left">
270+
<font size="8"/>
271+
</textElement>
272+
<textFieldExpression><![CDATA[" of " +$V{PAGE_NUMBER}]]></textFieldExpression>
273+
</textField>
274+
<textField pattern="d-M-yyyy h:mm:ss a">
275+
<reportElement x="0" y="0" width="178" height="20" uuid="ffd558c2-8b05-4669-8142-a7fdbc3ed46a"/>
276+
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
277+
</textField>
278+
<line>
279+
<reportElement x="0" y="0" width="552" height="1" uuid="1f1cab28-cf5b-4f72-954b-8e7f3ffd32e2"/>
280+
<graphicElement>
281+
<pen lineWidth="0.5" lineStyle="Solid" lineColor="#9E9E9E"/>
282+
</graphicElement>
283+
</line>
284+
</band>
285+
</pageFooter>
286+
</jasperReport>

examples/groups.php

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
include "main.php";
3+
4+
use simitsdk\phpjasperxml\PHPJasperXML;
5+
$filename = __DIR__.'/groups.jrxml';
6+
7+
$data = [];
8+
$faker = Faker\Factory::create('en_US');
9+
for($i=0;$i<100;$i++)
10+
{
11+
$tmp=[
12+
'fullname' => $faker->name(),
13+
'email' => $faker->email(),
14+
'gender' => $faker->randomElement(['M', 'F']),
15+
'user_id'=> $i+100008,
16+
'description'=>"Begin $i.\n".$faker->realText(70)."\n".$faker->realText() ."\n Ending",
17+
'country_code'=>$faker->randomElement(['SG','US','MY']),
18+
'groupname'=>$faker->randomElement(['Single','Married','Divorced']),
19+
'created'=>$faker->date("Y-m-d H:i:s")
20+
21+
];
22+
$data[$i]=$tmp;
23+
}
24+
25+
26+
$config = ['driver'=>'hasharray','data'=>$data];
27+
28+
$report = new PHPJasperXML();
29+
$report->load_xml_file($filename)
30+
->setDataSource($config)
31+
->export('Pdf');
32+

examples/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<option value="barcodes.php">Barcodes</option>
1818
<option value="formating.php">Elements Format Setting</option>
1919
<option value="invoice.php">Sample invoice</option>
20+
<option value="groups.php">Groups</option>
21+
<option value="vertical.php">Multicolumn (Vertical)</option>
22+
<option value="horizontal.php">Multicolumn (Horizontal)</option>
2023

2124
<!-- <option value="example1.php">Images</option>
2225
<option value="example1.php">Database</option>

examples/invoice.jrxml

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ now() as invoicedate,
103103
<reportElement x="0" y="240" width="550" height="500" uuid="29a4fd89-9923-4767-b793-d6b278e0367a"/>
104104
</rectangle>
105105
<textField>
106-
<reportElement x="35" y="410" width="480" height="210" forecolor="#949494" uuid="ba6b1b9c-c76c-429a-94ec-b8f4d9b777ac"/>
106+
<reportElement x="35" y="310" width="480" height="370" forecolor="#949494" uuid="ba6b1b9c-c76c-429a-94ec-b8f4d9b777ac"/>
107107
<textElement textAlignment="Center" verticalAlignment="Middle">
108-
<font fontName="Times" size="60" isBold="true"/>
108+
<font fontName="Times" size="70" isBold="true"/>
109109
</textElement>
110110
<textFieldExpression><![CDATA[$F{statustxt}]]></textFieldExpression>
111111
</textField>

examples/invoice.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
'termname'=>'30 Days',
3333
'invoicedate'=> date('Y-m-d'),
3434
'itemname'=>'Item '. ($i+1),
35-
'description'=>$faker->text(800),
35+
'description'=>$faker->text( $faker->numberBetween(200,2000)),
3636
'qty'=>$qty,
3737
'unit'=>'Ea',
3838
'unitprice'=> $unitprice,

0 commit comments

Comments
 (0)