开发者

how to convert String to Double in jasper Report?

开发者 https://www.devze.com 2023-01-15 06:27 出处:网络
How to convert String to Double value in jasper Reports? I am having two fields in .jrxml file like below

How to convert String to Double value in jasper Reports? I am having two fields in .jrxml file like below

    <field name="secRate" class="java.lang.String"/>
    <field name="secPri开发者_如何学运维ce" class="java.lang.String"/>

i need to subtract both the field

   $V{Variable} = $F{secRate} - SF{secPrice}

i tried this way but not working

  (new Double(Double.parseDouble($F{mktVal})))

any idea? please help me guys..


If the mktVal field is a String, you can try using Double.valueOf(${mktVal}).


  1. Set Text Field Expression: Double.parseDouble($F{PARAM})
  2. Set Expression Class: java.lang.Double
  3. Add rt.jar (from java runtime) to classpath [Tools >> Options >> Classpath]
  4. And Compile


Try

Double.valueOf(${mktVal}).


Pls try this one - ($F{PARAM}.trim().isEmpty()) ? 0.0 : new Double($F{PARAM})

0

精彩评论

暂无评论...
验证码 换一张
取 消