Change the Number format as per the parameter pass in jasper report -
this question has answer here:
my query is
when user selects language german, number should displayed in format - thousand separator should , decimal separator should .
when selected language english, number should displayed in format - thousand separator should . (standard) decimal separator should , (standard)
can change number format per parameter change?
it can done changing property setting particular field in ireport or can change directly in xml file.
you can take refrance below code.
<?xml version="1.0" encoding="utf-8"?> <jasperreport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="format_as_current" pagewidth="595" pageheight="842" whennodatatype="allsectionsnodetail" columnwidth="555" leftmargin="20" rightmargin="20" topmargin="20" bottommargin="20"> <parameter name="intparam" class="java.lang.integer"> <defaultvalueexpression><![cdata[12345678]]></defaultvalueexpression> </parameter> <parameter name="strparam" class="java.lang.string"> <defaultvalueexpression><![cdata["12345678.95"]]></defaultvalueexpression> </parameter> <title> <band height="79" splittype="stretch"> <textfield> <reportelement x="137" y="18" width="291" height="20"/> <textelement/> <textfieldexpression><![cdata[new java.text.decimalformat("$ #,##0.00").format($p{intparam})]]></textfieldexpression> </textfield> <textfield> <reportelement x="137" y="48" width="291" height="20"/> <textelement/> <textfieldexpression><![cdata[new java.text.decimalformat("$ #,##0.00").format(double.valueof($p{strparam} != null && $p{strparam}.length() > 0 ? double.valueof($p{strparam}) : 0))]]></textfieldexpression> </textfield> </band> </title>
Comments
Post a Comment