DonX
DonX

Reputation: 16379

Printing serial number in jasper report detail

I have created a jasper report. In that report in detail areaI have "serialNumber" column. That column wants to be auto incrementive and stats with "1". I am using hibernate for query. Sample code is :

<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 serial number in jasper report.

Upvotes: 2

Views: 10350

Answers (4)

FIFA oneterahertz
FIFA oneterahertz

Reputation: 720

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

I will show an image for better understandingenter image description here

Upvotes: 0

Mayur Bhokase
Mayur Bhokase

Reputation: 477

You Can use alternate solution for this problem that build in Variable $V{REPORT_COUNT}.

This variable will return the row count in Integer format.

Sample Expression :

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

Upvotes: 1

DonX
DonX

Reputation: 16379

Using variable we can achieve that.

Sample code :

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

Depends on the requirement we have to change expression

Upvotes: 5

Aaron Digulla
Aaron Digulla

Reputation: 328810

You have to bind the column to a bean which returns incrementing numbers.

Upvotes: 1

Related Questions