2011-12-06 6 views

답변

8

당신은 Background Band의 도움으로 문제를 해결할 수 있습니다.

나는 Background BandstaticText 요소를 넣어 Opaquemode 속성을 설정하고 backcolor 속성을 설정했습니다.

샘플 :

<jasperReport ... pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0"> 
    <property name="ireport.zoom" value="1.0"/> 
    <property name="ireport.x" value="0"/> 
    <property name="ireport.y" value="338"/> 
    <queryString language="xPath"> 
     <![CDATA[/Northwind/Customers]]> 
    </queryString> 
    <field name="CustomerID" class="java.lang.String"> 
     <fieldDescription><![CDATA[CustomerID]]></fieldDescription> 
    </field> 
    <field name="CompanyName" class="java.lang.String"> 
     <fieldDescription><![CDATA[CompanyName]]></fieldDescription> 
    </field> 
    <field name="ContactName" class="java.lang.String"> 
     <fieldDescription><![CDATA[ContactName]]></fieldDescription> 
    </field> 
    <field name="ContactTitle" class="java.lang.String"> 
     <fieldDescription><![CDATA[ContactTitle]]></fieldDescription> 
    </field> 
    <field name="Address" class="java.lang.String"> 
     <fieldDescription><![CDATA[Address]]></fieldDescription> 
    </field> 
    <field name="City" class="java.lang.String"> 
     <fieldDescription><![CDATA[City]]></fieldDescription> 
    </field> 
    <field name="PostalCode" class="java.lang.String"> 
     <fieldDescription><![CDATA[PostalCode]]></fieldDescription> 
    </field> 
    <field name="Country" class="java.lang.String"> 
     <fieldDescription><![CDATA[Country]]></fieldDescription> 
    </field> 
    <field name="Phone" class="java.lang.String"> 
     <fieldDescription><![CDATA[Phone]]></fieldDescription> 
    </field> 
    <field name="Fax" class="java.lang.String"> 
     <fieldDescription><![CDATA[Fax]]></fieldDescription> 
    </field> 
    <background> 
     <band height="842" splitType="Stretch"> 
      <staticText> 
       <reportElement mode="Opaque" x="0" y="0" width="595" height="842" backcolor="#CCFFCC"/> 
       <textElement/> 
       <text><![CDATA[]]></text> 
      </staticText> 
     </band> 
    </background> 
    <title> 
     <band height="79" splitType="Stretch"> 
      <staticText> 
       <reportElement x="128" y="29" width="298" height="20"/> 
       <textElement textAlignment="Center" verticalAlignment="Middle"> 
        <font isBold="true"/> 
       </textElement> 
       <text><![CDATA[The report with the background color]]></text> 
      </staticText> 
     </band> 
    </title> 
    <detail> 
     <band height="20" splitType="Stretch"> 
      <textField> 
       <reportElement x="19" y="0" width="147" height="20"/> 
       <box leftPadding="10"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{CompanyName}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="166" y="0" width="260" height="20"/> 
       <box leftPadding="10"/> 
       <textElement/> 
       <textFieldExpression><![CDATA[$F{City}]]></textFieldExpression> 
      </textField> 
     </band> 
    </detail> 
</jasperReport> 

Background Band의 높이는 전체 보고서의 높이와이 밴드의 전체 공간을 차지해야합니다 "투명"staticText 요소 같아야한다.

결과는 다음과 같습니다 Alex..it 작동 report with background color

+0

감사합니다 .. – Priya

+0

는 배경 이미지와 보고서를 만드는 데 도와주었습니다. 고마워! –

관련 문제