Jump to content
We've recently updated our Privacy Statement, available here ×

Format in Brazillian Currency (Real - R$) style


adan.ribeiro
Go to solution Solved by adan.ribeiro,

Recommended Posts

Hi!
I am using iReport Designer 5.5.1 with PHPJasperXML.

I developed a simple report with four columns where one of them shows up some values in Brazilian currency, but it didn't work. The report only prints the number without any aditional symbol. Well, I've tried to format this one with the following code:

<textField pattern="¤ #,##0.00">    <reportElement x="98" y="0" width="76" height="20" uuid="fc59b1a9-2fb7-4557-9e3c-9a54c79dd8b0"/>    <textElement textAlignment="Right"/>    <textFieldExpression><![CDATA[$F{Valor}]]></textFieldExpression>   </textField>[/code]

MySQL has this field set as FLOAT (10,2), so do I checked for the same value in properties panel and I figured out that EXPRESSION CLASS property was set as "java.lang.string". I've changed this one to "java.lang.float" but nothing happened. 

I really appreciate any help with it. Thanks!

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • Solution
Well, I solved my own issue using MySQL statement instead of properties from iReport. My solution was an adaptation from this site (Pt-BR): 

 


 

Then I just replaced the value in the sentence by field "valor_aquisicao" like this:

 

SELECT CONCAT('R$ ',REPLACE(REPLACE(REPLACE(FORMAT(valor_aquisicao, 2), '.', '|'), ',', '.'), '|', ',')) AS 'Valor' FROM [...rest of statement...]

 

It suited very well and fixed my problem. as you can see in this image below.

 

00adan(1).jpg.253bb0577fea2e38d53dcdbd7a19dfc4.jpg

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...