Jasper Report is an awesome open source Java reporting tool. It is used to generate dynamic reports using .jasper or JRXML file.
Jasper report contains several bands:
- Title:
This band is printed only once at the beginning of the generated document. - Page Header:
This band is printed at the beginning on each page of the generated document. - Column Header:
This band is printed at the beginning of each column of the generated document. - Detail:
This band is printed multiple times depending upon the numbers of items supplied data source have. A jasper report can have multiple detail bands. - Column Footer:
This band is printed at the bottom of each column of the generated document. - Page Footer:
This band is printed at the bottom of each page of the generated document. - Summary:
This band is printed only once after the detail bands in the generated document.
These are the main bands in a jasper report. Except these bands, a jasper report can also have following bands:
- Last Page Footer:
This band is printed at the bottom of the last page of the generated document. This band replaces the Page Footer band of the last page, i.e., this band is printed instead of the Page Footer band on the last page of the generated document. - No Data:
This band is printed if “When No Data” property of the report is set to “No Data Section” and provided data source is empty. - Background:
This band is printed on every page of the generated document. All the elements in this band are printed in the background. All the other band elements are printed on the top of this background band. This band is generally used to print watermarks on the document.
That’s all about jasper report bands.
I have created a sample jasper report to demonstrate these bands in action:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
[code] <?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="testReport" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="cfab0db2-a23a-417c-80fa-bac43912f0b4"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="186"/> <style name="border"> <box> <pen lineWidth="1.0" lineColor="#000000"/> <topPen lineWidth="1.0" lineColor="#000000"/> <leftPen lineWidth="1.0" lineColor="#000000"/> <bottomPen lineWidth="1.0" lineColor="#000000"/> <rightPen lineWidth="1.0" lineColor="#000000"/> </box> </style> <queryString> <![CDATA[SELECT language.`id` AS id, language.`name` AS name FROM `language` language LIMIT 5]]> </queryString> <field name="id" class="java.lang.Long"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band height="802" splitType="Stretch"> <staticText> <reportElement x="0" y="0" width="555" height="802" forecolor="#CFD7DB" uuid="6170ad9e-59b5-45a1-8eea-4f66e2c1a83d"/> <textElement textAlignment="Center" verticalAlignment="Middle" rotation="Left"> <font size="60"/> </textElement> <text><![CDATA[JellyFish Technologies]]></text> </staticText> </band> </background> <title> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="6592973d-6527-43ed-b50c-7c27f18315d8"/> <box topPadding="0" leftPadding="0" bottomPadding="0" rightPadding="0"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[TITLE]]></text> </staticText> </band> </title> <pageHeader> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="bc9fb8af-15de-41c6-8456-d98d5f7b6cf1"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[PAGE HEADER]]></text> </staticText> </band> </pageHeader> <columnHeader> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="99a4d96a-312f-47a6-98da-6ae8d3f40c56"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[COLUMN HEADER]]></text> </staticText> </band> </columnHeader> <detail> <band height="125" splitType="Stretch"> <textField> <reportElement style="border" x="0" y="0" width="555" height="125" uuid="9a76c63c-5385-4f49-abc1-9f7fa9427198"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="18f0ae8e-0a01-4bdb-80ac-e48963dad884"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[COLUMN FOOTER]]></text> </staticText> </band> </columnFooter> <pageFooter> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="0e2cefd1-832c-452d-ad04-2ecdad6e8422"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[PAGE FOOTER]]></text> </staticText> </band> </pageFooter> <lastPageFooter> <band height="25"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="1a7cab0d-2066-4e97-8931-abb17bb3a531"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[LAST PAGE FOOTER]]></text> </staticText> </band> </lastPageFooter> <summary> <band height="25" splitType="Stretch"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="25" uuid="98b792b7-ab0f-4d44-86db-44bed55770a6"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[SUMMARY]]></text> </staticText> </band> </summary> <noData> <band height="50"> <staticText> <reportElement style="border" x="0" y="0" width="555" height="50" uuid="c39b266f-a1d2-4050-98a4-2b32cd1a87f3"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="12"/> </textElement> <text><![CDATA[NO DATA]]></text> </staticText> </band> </noData> </jasperReport> [/code] |
And following are some images of the different document I have generated:
- Multipage Document Demo:
First Page:Second Page:
- No Data Band Demo:
- Background Band Demo:
Note:- I have used iReport(v5.5.0) to design this jasper report.
Enjoy Coding 🙂 .
Recent Comments