Problemas para gerar uma expressão com divisão no ireport

2 respostas
M

Bom dia

Quero colocar no meu relatório o valor de determinado item, que é calculado TOTAL / PESO

(Double.valueOf($F{total}) == 0.00 ? 0.00 : new BigDecimal($F{total}).divide(new BigDecimal($F{weight})))

sem a divisão esta funcionando
(Double.valueOf($F{total}) == 0.00 ? 0.00 : new BigDecimal($F{total}))

erro:

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :

Source text : (Double.valueOf($F{total}) == 0.00 ? 0.00 : new BigDecimal($F{total}).divide(new BigDecimal($F{weight})))

at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:193)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:570)

at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:538)

at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:868)

at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:368)

alguma dica???

2 Respostas

V

Cara tenta assim

new StringBuffer().append(new BigDecimal("0.01").equals(new BigDecimal("0.00")) ? new BigDecimal("0.00") :  new BigDecimal(10).divide(new BigDecimal(2))).toString()
M

Vitor, obrigado pela ajuda, mas acabei fazendo da seguinte forma

new DecimalFormat(Currency.getInstance(Locale.getDefault()).getSymbol() + "0.00").format(Double.valueOf($F{total}) == 0.00 ? 0.00 : (Double.parseDouble($F{total}) / Double.parseDouble($F{weight})))
Criado 12 de agosto de 2010
Ultima resposta 13 de ago. de 2010
Respostas 2
Participantes 2