如何在iReport中添加符号Turkish(土耳其里拉) [英] How to add a symbol ₺ (Turkish Lira) in iReport
问题描述
$ P {DETAILPARAM} =Tarihindenbugünekadar< style isBold ='true'pdfFontName ='DejaVu Sans'>+ new java.text.DecimalFormat(# ,## 0.00)。格式($ F {TOTAL_DEBT})+₺< / style>Borcunuzvardır。
字体= DejaVu Sans
这就像添加 $ P {DETAILPARAM参数中的
。并导出PDF,但不要显示₺这个符号。
我该怎么办?
这是我的jrxml代码:
< jasperReport xmlns =http://jasperreports.sourceforge.net/jasperreportsxmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexsi: schemaLocation =http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsdname =FontTestpageWidth =595pageHeight =842whenNoDataType =AllSectionsNoDetail columnWidth =555leftMargin =20rightMargin =20topMargin =20bottomMargin =20uuid =2347c131-1884-430a-b77f-59f08f896c8a>
< parameter name =numberclass =java.lang.DoubleisForPrompting =false>
< defaultValueExpression><![CDATA [new Double(1000.23)]]>< / defaultValueExpression>
< /参数>
< queryString>
<![CDATA []]>
< / queryString>
< title>
< band height =25>
< textField>
< reportElement x =0y =0width =100height =25uuid =bc2ae040-f9af-4732-82fe-8fe8b71696bd/>
< textElement>
< font fontName =DejaVu Serifsize =14/>
< / textElement>
< textFieldExpression><![CDATA [\ u20BA]]>< / textFieldExpression>
< / textField>
< textField pattern =₺#,## 0.00>
< reportElement x =100y =0width =200height =25uuid =ee49d149-394b-4ac6-a0a2-6d207b0c8d89/>
< textElement>
< font fontName =DejaVu Serifsize =14/>
< / textElement>
< textFieldExpression><![CDATA [$ P {number}]]>< / textFieldExpression>
< / textField>
< / band>
< / title>
< / jasperReport>
一些设计说明:
-
格式化数字时,最好应用
pattern
,因为如果导出到例如excel,这将保持正确的类。 -
我无法实现模式
\ u20BA#,## 0.00
即使这个直接在java中工作,我需要进一步研究这个,看起来像jasper报告正在做一个替换\,不得不把char直接放在模式中(即使这不推荐)。
$P{DETAILPARAM} = " Tarihinden bu güne kadar <style isBold='true' pdfFontName='DejaVu Sans'>"+new java.text.DecimalFormat("#,##0.00").format($F{TOTAL_DEBT})+" ₺ </style> Borcunuz vardır."
Font = DejaVu Sans
This like add $P{DETAILPARAM}
in parameter. And export PDF, but do not show "₺" this symbol.
What must I do?
The Turkish Lira has unicode U+20BA
and since it fairly new (2012) you need to be sure that this unicode is supported by your selected font .
I tried with the font dejavu-serif, to understand how to download and install correctly see: How can I display "$£Ω€απ⅔" in Jasperserver PDF using iReport?
Result
This was my jrxml code:
<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="FontTest" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="2347c131-1884-430a-b77f-59f08f896c8a">
<parameter name="number" class="java.lang.Double" isForPrompting="false">
<defaultValueExpression><![CDATA[new Double(1000.23)]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[]]>
</queryString>
<title>
<band height="25">
<textField>
<reportElement x="0" y="0" width="100" height="25" uuid="bc2ae040-f9af-4732-82fe-8fe8b71696bd"/>
<textElement>
<font fontName="DejaVu Serif" size="14"/>
</textElement>
<textFieldExpression><![CDATA["\u20BA"]]></textFieldExpression>
</textField>
<textField pattern="₺ #,##0.00">
<reportElement x="100" y="0" width="200" height="25" uuid="ee49d149-394b-4ac6-a0a2-6d207b0c8d89"/>
<textElement>
<font fontName="DejaVu Serif" size="14"/>
</textElement>
<textFieldExpression><![CDATA[$P{number}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Some design notes:
When formatting numbers it is better to apply
pattern
, since this will keep correct class if exported to for example excel.I could not achieve the pattern
"\u20BA #,##0.00"
even if this works directly in java, I need to further investigate this, seems like jasper report is doing a replacement of the "\" had to put the char directly in pattern (even if this is not recommend).
这篇关于如何在iReport中添加符号Turkish(土耳其里拉)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!