views:

452

answers:

2

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.

+1  A: 

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

Aaron Digulla
+2  A: 

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

BlackPanther