Jasper reports 在多页上分组时,总和不正确
我正在JasperSoft Studio上构建一个包含多个组的报告,并尝试获取每个组的两列值之和。我能够成功地生成报告并获得大多数正确的值,但我注意到,当且仅当组中的所有值都在同一页上时,每个组的总和都是准确的,否则,我会得到错误的总和 这是.jrxml中定义组的部分:Jasper reports 在多页上分组时,总和不正确,jasper-reports,Jasper Reports,我正在JasperSoft Studio上构建一个包含多个组的报告,并尝试获取每个组的两列值之和。我能够成功地生成报告并获得大多数正确的值,但我注意到,当且仅当组中的所有值都在同一页上时,每个组的总和都是准确的,否则,我会得到错误的总和 这是.jrxml中定义组的部分: <group name="customer-tree"> <groupFooter> <band height="30"> <proper
<group name="customer-tree">
<groupFooter>
<band height="30">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<frame>
<textField>
<reportElement x="1407" y="0" width="66" height="30" uuid="cd6ad251-ee00-480a-bab7-04e1b094448b"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{customer-tree_billing-total}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="1473" y="0" width="72" height="30" uuid="d2424c64-8449-4c75-aca8-69244b990d44"/>
<textElement textAlignment="Right" verticalAlignment="Top">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{customer-tree_total}]]></textFieldExpression>
</textField>
</frame>
</band>
</groupFooter>
</group>
这些是用于求和的变量的定义:
<variable name="customer-tree_total" class="java.lang.Long" resetType="Group" resetGroup="customer-tree" incrementType="Column" calculation="Sum">
<variableExpression><![CDATA[$V{customer-tree_total} + $F{total_calls}]]></variableExpression>
<initialValueExpression><![CDATA[0L]]></initialValueExpression>
</variable>
<variable name="customer-tree_billing-total" class="java.lang.Long" resetType="Group" resetGroup="customer-tree" incrementType="Column" calculation="Sum">
<variableExpression><![CDATA[$V{customer-tree_billing-total} + $F{billing_days}]]></variableExpression>
<initialValueExpression><![CDATA[0L]]></initialValueExpression>
</variable>
我已经尝试过的事情:
- 使用不同的查询参数。当一个组中的所有结果不能放在一个页面上时,我只能看到错误的值,我通过将
添加到源代码中查看一个页面上的所有结果来确认这一点。在这种情况下,所有组的总和都是准确的 - 将参数和相关变量类型全部更改为
(而不是java.lang.Integer
),以查看java.lang.Long
表达式是否会受到影响 - 将参数保留为
,并使用java.lang.Long
的Long
将其添加到相关变量中intValue()
<variable name="customer-tree_total" class="java.lang.Long" resetType="Group" resetGroup="customer-tree" calculation="Sum">
<variableExpression><![CDATA[$F{total_calls}]]></variableExpression>
<initialValueExpression><![CDATA[0L]]></initialValueExpression>
</variable>
<variable name="customer-tree_billing-total" class="java.lang.Long" resetType="Group" resetGroup="customer-tree" calculation="Sum">
<variableExpression><![CDATA[$F{billing_days}]]></variableExpression>
<initialValueExpression><![CDATA[0L]]></initialValueExpression>
</variable>
尝试删除incrementType=“Column”并在变量表达式中只留下$F{..}。哇@dada67,我不敢相信这真的有效。。。谢谢你想正式回答这个问题,这样我就可以正式接受你的回答了吗。