Serial number printing on jasper report detail

I created a jasper report. This report details the serialNumber column. This column wants to be auto-incremented, and the statistics with "1". I am using hibernate

to request. Sample code:

<detail>
    <band height="17" splitType="Stretch">
        <textField isBlankWhenNull="true">
            <reportElement x="12" y="0" width="27" height="15"/>
            <textElement/>
            <textFieldExpression class="java.lang.Integer"><![CDATA[serialNumber]]>
            </textFieldExpression>
        </textField>
        <textField>
            <reportElement x="51" y="0" width="37" height="15"/>
            <textElement textAlignment="Center" verticalAlignment="Middle"/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{date}]]>
            </textFieldExpression>
        </textField>
        <textField>
            <reportElement x="138" y="0" width="75" height="15"/>
            <textElement textAlignment="Center" verticalAlignment="Middle"/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]>
            </textFieldExpression>
        </textField>
    </band>
</detail>

      

Can anyone help to print the serial number in the jasper report.

+2


source to share


4 answers


By using a variable we can achieve this.

Sample code:



 <variable name="seraialNumber" class="java.lang.Integer" resetType="None" 
calculation="Count"/>

      

Depending on the requirement, we must change the expression

+5


source


You need to bind the column to a bean that returns incremental numbers.



+1


source


You can use an alternative solution for this problem, which is created in the $ V {REPORT_COUNT} variable.

This variable will return the number of lines in Integer format.

Expression example:

<textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>.

      

+1


source


<variable name="serial number" class="java.lang.Integer" resetType="Column" calculation="Count">
        <variableExpression><![CDATA[0]]></variableExpression>
    </variable>

      

I will show an image for better understanding enter image description here

0


source







All Articles