2009-10-22 54 views
0

当我尝试在碧玉报告中的图表元素(图表名称)内显示中文字符时,它不显示,我使用i18n从属性文件中取值,它读取键但不显示中文字符。它不显示除英语之外的任何字符。在碧玉报告中的图表元素中添加中文字符

这是我的JRXML:

<parameter name="orgId" isForPrompting="true" class="java.lang.String"/> 
<parameter name="time" isForPrompting="true" class="java.lang.String"/> 
<parameter name="chartName" isForPrompting="true" class="java.lang.String"/> 
<parameter name="url" isForPrompting="true" class="java.lang.String"/> 
<parameter name="wwidth" isForPrompting="true" class="java.lang.String"/> 
<parameter name="wheight" isForPrompting="true" class="java.lang.String"/> 
<parameter name="sql" isForPrompting="true" class="java.lang.String"/> 
<queryString><![CDATA[$P!{sql}]]></queryString> 

<field name="ROWNUM" class="java.math.BigDecimal"/> 
<field name="CCOUNT" class="java.math.BigDecimal"/> 
<field name="CONTROL_ID" class="java.math.BigDecimal"/> 
<field name="CONTROL_CODE" class="java.lang.String"/> 
<field name="CONTROL_NAME" class="java.lang.String"/> 

    <background> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </background> 
    <title> 
     <band height="20" isSplitAllowed="true" > 
      <textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > 
       <reportElement 
        x="0" 
        y="0" 
        width="403" 
        height="19" 
        key="textField-1"/> 
       <box leftPadding="5"></box> 
       <textElement> 
        <font fontName="Trebuchet MS" pdfFontName="Helvetica-Bold" isBold="true"/> 
       </textElement> 
      <textFieldExpression class="java.lang.String"><![CDATA[(($P{time}!=null && !$P{time}.equals("")) ? str($P{chartName}) : "")]]></textFieldExpression> 
      </textField> 
     </band> 
    </title> 
    <pageHeader> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </pageHeader> 
    <columnHeader> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </columnHeader> 
    <detail> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </detail> 
    <columnFooter> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </columnFooter> 
    <pageFooter> 
     <band height="0" isSplitAllowed="true" > 
     </band> 
    </pageFooter> 
    <summary> 
     <band height="222" isSplitAllowed="true" > 
      <bar3DChart> 
       <chart hyperlinkTarget="Self" > 
       <reportElement 
        x="0" 
        y="0" 
        width="403" 
        height="222" 
        key="element-1"/> 
       <box></box> 
        <chartTitle color="#000000" > 
       <font fontName="Trebuchet MS" pdfFontName="Helvetica" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="false" pdfEncoding="Cp1252"/> 
          <titleExpression><![CDATA[str("chartName")]]></titleExpression> 
       </chartTitle> 
        <chartLegend textColor="#000000" backgroundColor="#FFFFFF" > 
       </chartLegend> 
       </chart> 
       <categoryDataset> 
        <dataset > 
        </dataset> 
        <categorySeries> 
         <seriesExpression><![CDATA[$F{CONTROL_CODE}]]></seriesExpression> 
         <categoryExpression><![CDATA[$F{CONTROL_NAME}]]></categoryExpression> 
         <valueExpression><![CDATA[$F{CCOUNT}]]></valueExpression> 
      <itemHyperlink hyperlinkType="Reference"> 
        <hyperlinkReferenceExpression><![CDATA["javascript:void(0);window.open('"+$P{url}+"&fileName=topControlsDrilldown&conName="+$F{CONTROL_NAME}+"&conId="+$F{CONTROL_ID}+"','TopControls','width="+$P{wwidth}+",height="+$P{wheight}+",top=300,left=250,menubar=0');location.reload()"]]></hyperlinkReferenceExpression> 
        <hyperlinkTooltipExpression><![CDATA[""+$F{CCOUNT}]]></hyperlinkTooltipExpression> 
      </itemHyperlink> 
        </categorySeries> 
       </categoryDataset> 
       <bar3DPlot isShowLabels="true" > 
        <plot orientation="Horizontal" foregroundAlpha="0.7" > 
         <seriesColor seriesOrder="0" color="#615A4A"/> 
         <seriesColor seriesOrder="1" color="#88A3BF"/> 
         <seriesColor seriesOrder="2" color="#B47272"/> 
         <seriesColor seriesOrder="3" color="#E8A4EA"/> 
         <seriesColor seriesOrder="4" color="#FFC189"/> 
         <seriesColor seriesOrder="5" color="#FFEF79"/> 
         <seriesColor seriesOrder="6" color="#AFFAFF"/> 
         <seriesColor seriesOrder="7" color="#F7A7AB"/> 
         <seriesColor seriesOrder="8" color="#A7A1FF"/> 
         <seriesColor seriesOrder="9" color="#E7CEAD"/> 

回答

0

在文本框的属性对话框中,你应该设置适当的PDF编码。您正在使用CP1252,这对拉丁字符而言不错,但不适用于中文。

+0

为了改善您的答案:* *是否支持中文的正确编码? (UTF-8也许?) – jtbandes

+0

多数民众赞成正是为什么我没有指定:),我认为UTF-8会很好,但我尝试了阿拉伯字符,并没有正常工作,所以我切换到CP1256。 UTF-8可能对中国人有好处,不确定。 – medopal