Search code examples
jasper-reports

How to convert number to words (iReport)


I want to convert for example, 1000 to one thousand (currency). How can i do it in Jasper?


Solution

    1. See http://www.rgagnon.com/javadetails/java-0426.html
    2. Create a class based on the given implementation.
    3. Compile the class and put it in a directory where iReport can read the file.
    4. Update the CLASSPATH in iReport to point to the directory containing the class (be aware of directory relationships to package namespaces).
    5. Restart iReport.
    6. Change the text field expression to: EnglishNumberToWords.convert( $F{field_name} )

    You will have to change field_name and the data type of the convert method according to your implementation details.