如何对 jxls 模板中的非连续单元格求和

发布于 2024-09-18 00:00:42 字数 1056 浏览 15 评论 0原文

我正在从模板创建一个 xls 报告,该报告使用从 Oracle 数据库获取的数据。我有一个小组和一个小组。在子组中,我创建一个表,显示 PREMIUM 值,然后使用以下方法显示总计:

$[SUM(I18)]

由于此处的值是连续的,因此该公式将转换为 SUM(I18:I35)。

显示所有子组后,我想显示子组中所有 PREMIUMS 的总和,为此,我使用:

$[SUM(I21)]

jxls 足够智能,可以将其转换为 SUM(I36, I46, I67, ...) 这就是我的位置遇到问题。可以传递给 SUM 函数的参数数量有一些限制。有什么想法如何对 xls 模板中的集合进行求和吗?

我的模板看起来像:

<jx:forEach items="${group.items}"  groupBy="client">     
 <jx:forEach items="${group.items}"  groupBy="contract">    
  <jx:forEach items="${group.items}" var="result">   
  PREMIUM  
  ${result.premium}  
  </jx:forEach>  
 Group Total $[SUM(I18)]  
 </jx:forEach>   
 Total $[SUM(I20)] // This is where the problem
                   // is because Group Total are not consecutive 
</jx:forEach> 

我也尝试过:

 ${group.items.premium}
 Total $[SUM(I22)]

并隐藏了 ${group.items.premium} 的行,但是当生成模板时,它会取消隐藏行...

如果您知道 jsxl 教程的好资源或类似的东西请张贴在这里。我真的很难找到血统的东西......

I am creating a xls report from template that uses data obtained from the Oracle database. I have a group and a subgroup. In a subgroup I create a table that displays the PREMIUM values and then the total using:

$[SUM(I18)]

Because values here are consecutive this formula is converted to i.e. SUM(I18:I35).

After all subgroups are displayed I want to show the total of all PREMIUMS from the subgroups, to do this I use:

$[SUM(I21)]

jxls is smart enough to convert it to i.e. SUM(I36, I46, I67, ...) And this is where I come across a problem. There is some limit as to how many parameters can be passed in to SUM function. Any ideas how can I do the SUM on the collection in xls template?

My template looks like:

<jx:forEach items="${group.items}"  groupBy="client">     
 <jx:forEach items="${group.items}"  groupBy="contract">    
  <jx:forEach items="${group.items}" var="result">   
  PREMIUM  
  ${result.premium}  
  </jx:forEach>  
 Group Total $[SUM(I18)]  
 </jx:forEach>   
 Total $[SUM(I20)] // This is where the problem
                   // is because Group Total are not consecutive 
</jx:forEach> 

I as well tried:

 ${group.items.premium}
 Total $[SUM(I22)]

and made the row with ${group.items.premium} in it hidden but when the template is generated it unhides the rows...

As well if you know a good resource with jsxl tutorial or something similar please post it here. I really struggle to find something descent...

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

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

发布评论

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

评论(1

灵芸 2024-09-25 00:00:42

使用 jxls 聚合对您有用吗?

IE。
${sum(premium):group.items} // 每个“客户”组中所有保费的总和

<jx:forEach items="${group.items}"  groupBy="client">     
 <jx:forEach items="${group.items}"  groupBy="contract">    
  <jx:forEach items="${group.items}" var="result">   
  PREMIUM  
  ${result.premium}  
  </jx:forEach>  
 Group Total $[SUM(I18)]  
 </jx:forEach>   
 ${sum(premium):group.items} 
</jx:forEach> 

would using an jxls aggregate work for you?

ie.
${sum(premium):group.items} // sum all premiums in each "client" group

<jx:forEach items="${group.items}"  groupBy="client">     
 <jx:forEach items="${group.items}"  groupBy="contract">    
  <jx:forEach items="${group.items}" var="result">   
  PREMIUM  
  ${result.premium}  
  </jx:forEach>  
 Group Total $[SUM(I18)]  
 </jx:forEach>   
 ${sum(premium):group.items} 
</jx:forEach> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文