-1

My Query is
When user selects language as German, the number should be displayed in the format - thousand separator should be , decimal separator should be .

When selected language is English, the number should be displayed in the format - thousand separator should be . (standard) decimal separator should be , (standard)

Can we change the number format as per the parameter change?

Alex K
  • 22,315
  • 19
  • 108
  • 236
spruha
  • 1
  • 2

2 Answers2

0

It can be done by just changing property setting for that particular field in iReport or you can change directly in xml file.

You can Take refrance from 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>

Deepesh kumar Gupta
  • 884
  • 2
  • 11
  • 29
0

For any report, there is a parameter named $P{REPORT_LOCALE} Your can use this parameter to define the format of the number. The use of a third parameter, lets call it $P{Number_format} , you can define this format as per the locale.

spruha
  • 1
  • 2