当前位置: 动力学知识库 > 问答 > 编程问答 >

jasper reports - Add a variable to column footer iReport

问题描述:

I want to add a variable to column footer of my table. It is the sum of the column values. eg: total sales, if column name is sales.

But when i try it it says variable not found for some reason.

I have positioned the table in title band because if i put it in detail band the table repeats multiplied by the number of rows in the table.

5rows = 5pages with the same table.

Can someone please help me since im new to jasper and ireport.

I am using ireport 5.0.0

Thank you

网友答案:

Make sure you have this on your xml

<field name="total_column" class="java.lang.Long"/>

and have this as your text field expression

$F{total_column}

Change the name to whatever you are using.

网友答案:

We always define variables at the center level so make sure if you are using any sub data-set for your table component, copy the same query in main report query area, then add a variable and change these properties in Ireport :-

Variable class :- java.lang.integer or java.math.BigDecimal
Calculation :-     Sum
Variable expression:-  $F{total_sales}

XML:- if you are not using Ireport

  <variable name="total_sales" class="java.math.BigDecimal" calculation="Sum">
    <variableExpression><![CDATA[$F{total_sales}]]></variableExpression>
</variable>

and after this you can use this variable for sum.

分享给朋友:
您可能感兴趣的文章:
随机阅读: