Search code examples
jasper-reportsireport

Number Formatting in iReport


Can any body help me for giving pattern for a number?

Here is my problem.

I just wanted to display a number as "30.00",

Eventhough I had set the pattern as 2 decimal points it is not displayting the result as"30.00" instead it is showing the result as "30".

And one note is that for that field pattern it is shoeing an extra button as "ResetDefault". Is there is any problem with that button for this.

Can any one please solve this problem.


Solution

  • iReport has a bad habit of not changing the pattern on the jrxml when you just open and press OK (your format is default). Change something and then change it back, press OK and you are ready to GO.

    iReport set pattern

    If you are tired of iReport, you can also set pattern directly in jrxml:

    Example

    <textField pattern="###0.00;-###0.00">
        <reportElement x="100" y="0" width="100" height="20" uuid="1fccff95-408c-4364-b003-c691fefdde62"/>
        <textElement textAlignment="Right" verticalAlignment="Middle"/>
        <textFieldExpression><![CDATA[$F{myNumber}]]></textFieldExpression>
    </textField>