2

当我尝试在 Jasper 中计算表达式时遇到问题。运行报告后显示错误消息。

Error filling print... Error evaluating expression :      Source text : new Integer(($F{total_answer}.intValue()) / ($F{total_max_score}.intValue()*100)) 
Can't find the translation for key = time_picker: using default (Time)  Can't find the translation for key = time_picker: using default (Time)  For input string: ""  For input string: ""  java.lang.ArithmeticException: / by zero 

这是我的代码:

new Integer(($F{total_answer}.intValue()) / ($F{total_max_score}.intValue()*100))

有人知道吗?

4

1 回答 1

2

这是解决方案

如何在 jasper 报告中使用 divide() 方法?

并注意通过将初始值分配给 0 来检查无效性。

${total_answer}.divide( ${total_max_score} )

你可以对乘法做同样的事情.multiply()

于 2014-05-03T08:14:44.610 回答