iReport + XPath - 字符串列总和

发布于 2024-12-27 19:21:33 字数 366 浏览 2 评论 0原文

我正在构建一个报告,其中有一个子报告。该子报表通过 XPath 带来一些数据,这意味着它是来自 XML 的所有字符串。该子报告的其中一列有一些值,我需要对它们进行求和并显示在表的末尾。

我不知道如何让它发挥作用。我尝试使用 sum 参数创建一个变量,但它不起作用。

以前有人需要这个吗?

设想: 我从 XPath 查询加载很多值,例如: /something/something1/something2

这个查询根据我的需要返回一些字段。我用它们构建了一个表格(在子报表中)。问题是:最后一列 (4),值是来自 XML 的字符串。

iReport 版本:3.0.0

真的谢谢!

I'm building a report where I have a subreport. This subreport brings some data through XPath, this means it's everything strings from a XML. One of the columns of this subreport has some values, where I need do sum them and show in the end of the table.

I don't know how to put this to work. I've tried to create a variable with sum parameter, but it does not work.

Did anybody need this before?

Scenario:
I load a lot of values from a XPath query, e.g:
/something/something1/something2

This query returns some fields according to my needs. With them I build a table (in a subreport). The problem is: the last column (4), values are strings from XML.

iReport version: 3.0.0

Really thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朕就是辣么酷 2025-01-03 19:21:33

解决方案:

我需要什么?根据原始帖子,包含通过 XPath 从 XML 读取的字符串的列和包含总和的页脚。

SUM 列的结果

该怎么办?创建一个变量来保存总和。创建完成后,进行编辑。例如:在此处输入图像描述

用您需要的格式填充变量表达式。这里我用的是

new BigDecimal($F{theFieldToSum});

点击确定。现在变量已创建,您必须创建一个新的文本字段,在其中显示总和。创建它并编辑它。这里我使用了以下格式:

new java.text.DecimalFormat("#,##0.00").format($V{theVariableYouCreatedBefore})

单击“应用”即可。编译您的报告,现在您将获得预期的结果。当然,你可以做一些调整,但总的来说就是这个过程。

Solution:

What I needed? According to the original post, a column with strings read from a XML through XPath and a footer with the sum.

Result from column SUM

What to do? Create a variable where you'll keep your sum. After created, edit it. e.g:enter image description here

Fill variable expression with the format you need. Here I used

new BigDecimal($F{theFieldToSum});

Click ok. Now the variable is created, you must create a new TextField where you'll show your sum. Create it and edit it. Here I used the following format:

new java.text.DecimalFormat("#,##0.00").format($V{theVariableYouCreatedBefore})

Click "Apply" and that's all. Compile your report and now you'll have the expected result. For sure, you can do some adapt, but in general this is the process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文