2012-10-23 22 views
3

的JasperReports工作:的JasperReports:不支持與簽署當我使用風格

<style pdfFontName="Helvetica-BoldOblique" isBold="true" isItalic="true" 
forecolor="red">Instruction and instruction</style> 

JasperReports的不工作:

<style pdfFontName="Helvetica-BoldOblique" isBold="true" isItalic="true" 
forecolor="red">Instruction & instruction</style> 

爲什麼發生這種情況?

回答

2

我已經使用 & amp; amp; 而不是「&」,它正在碧玉報告中工作。

<style pdfFontName="Helvetica-BoldOblique" isBold="true" isItalic="true" 
forecolor="red">Instruction &amp;amp; instruction</style> 

//在文本字段中我使用了樣式標籤。

<textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" > 
       <reportElement 
        x="0" 
        y="0" 
        width="290" 
        height="15" 
        key="textField" 
        isRemoveLineWhenBlank="true"/> 
       <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" rightPadding="5" bottomBorder="None" bottomBorderColor="#000000"/> 
       <textElement textAlignment="Center" isStyledText="true"> 
        <font size="9"/> 
       </textElement> 
      <textFieldExpression class="java.lang.String"><![CDATA[<style pdfFontName="Helvetica-BoldOblique" isBold="true" isItalic="true" 
forecolor="red">Instruction &amp;amp; instruction</style>]]></textFieldExpression> 
      </textField> 
1

嘗試使用&amp;而是採用&符號。

工作樣例:

<?xml version="1.0" encoding="UTF-8"?> 
<jasperReport ... whenNoDataType="AllSectionsNoDetail"> 
    <style name="style1" forecolor="#FF0000" fontName="Serif" isBold="true" isItalic="true"/> 
    <title> 
     <band height="182" splitType="Stretch"> 
      <staticText> 
       <reportElement style="style1" x="27" y="15" width="515" height="20"/> 
       <textElement/> 
       <text><![CDATA[Instruction and instruction]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="style1" x="27" y="46" width="515" height="20"/> 
       <textElement/> 
       <text><![CDATA[Instruction & instruction]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="27" y="78" width="515" height="20"/> 
       <textElement markup="styled"/> 
       <text><![CDATA[<style isBold='true'>Instruction and instruction</style>]]></text> 
      </staticText> 
      <staticText> 
       <reportElement x="27" y="108" width="515" height="20"/> 
       <textElement markup="styled"/> 
       <text><![CDATA[<style isBold='true'>Instruction &amp; instruction</style>]]></text> 
      </staticText> 
     </band> 
    </title> 
</jasperReport> 

注:風格標記此示例中使用。

結果將是:

The preview in iReport


欲瞭解更多詳情,您可以查看Creating Styled Text Using a Markup Language職位和我的Style a text field in JasperReports問題的答案。

+0

謝謝,但它仍然無法正常工作。如果我寫出「&」超出樣式標記,它正在工作,但是,當我將它寫入樣式標記時,它不起作用。 –

+0

你的*標記*是什麼? –

+0

@IshwarPohani您可以將* jrxml *中的確切片段添加到您的問題中嗎?我會盡力檢查你的表情 –

相關問題