Format in Brazillian Currency (Real - R$) style

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>

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!

adan.ribeiro's picture
Joined: Jun 6 2014 - 8:32am
Last seen: 8 years 11 months ago

2 Answers:

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.
Format Brazilian Currency iReport
adan.ribeiro's picture
Joined: Jun 6 2014 - 8:32am
Last seen: 8 years 11 months ago

I'm using Japanese currency and everything works fine. I've just used Unicode characters in my pattern.

UMaking your sql complex reduces portability and decrease performance.

htshozawa's picture
665
Joined: Dec 7 2010 - 4:52pm
Last seen: 6 years 8 months ago

I also use Unicode and appropriated regional settings, but this wasn't show itself a good shot. I agree with you that to reduce the complexity of my statement will better the performance but I still have not found any other good option for it.

adan.ribeiro - 9 years 2 months ago
Feedback
randomness