Creating Alphabet Numbering on Jasper Report
Usually jasper report provide a numbering, accessible using REPORT_COUNT variable, but today my friend Edward Barchia asked me something interesting, how can i create a simple numbering using alphabet instead of number. Well basically, it’s actually quite easy.
Below is the image, how i do it.
Here is my complete jasper xml file,
<?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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="97dae3d4-5e81-4825-b4e7-cf3d1f77190f"> <property name="ireport.zoom" value="1.2100000000000002"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="42"/> <queryString language="SQL"> <![CDATA[select * from testing]]> </queryString> <field name="id" class="java.lang.Integer"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="address" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="20" splitType="Stretch"> <staticText> <reportElement x="50" y="0" width="100" height="20" uuid="f68bc18a-5471-4d4f-89ed-34d98bb06b6e"/> <text><![CDATA[name]]></text> </staticText> <staticText> <reportElement x="150" y="0" width="100" height="20" uuid="155f7ce1-e70c-4d93-8ebc-bad45d9f0ae1"/> <text><![CDATA[address]]></text> </staticText> <staticText> <reportElement x="0" y="0" width="50" height="20" uuid="48b8e6ef-1efd-4233-98f5-b2da6d273333"/> <text><![CDATA[No]]></text> </staticText> </band> </columnHeader> <detail> <band height="20" splitType="Stretch"> <textField> <reportElement x="50" y="0" width="100" height="20" uuid="3ffd3edf-b950-4dd9-8f13-ac8942e5bb8e"/> <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression> </textField> <textField> <reportElement x="150" y="0" width="100" height="20" uuid="236aec6c-34dc-4a54-ae2d-086c2a23786c"/> <textFieldExpression><![CDATA[$F{address}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="0" width="50" height="20" uuid="704b47d3-7dca-4f33-950a-a3efd0fb764b"/> <textFieldExpression><![CDATA["abcdefghijklmnopqrstuvwxyz".charAt( $V{REPORT_COUNT}-1 )]]></textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary> </jasperReport>