2013-04-16 217 views
3

我其中我需要顯示由邊界包圍的數據的截面的要求,這樣的:矩形邊框不顯示

enter image description here

我試圖與在背景技術中添加矩形部件做帶。在內部預覽窗口和PDF預覽中顯示如上,但是當我在服務器中運行它或使用HTML預覽時,邊框消失。我也嘗試在細節帶中插入矩形組件,並使用框架代替矩形,圍繞數據,但是存在相同的問題。

我正在使用iReport 5.0.1兼容性設置爲JasperReports 3.5.1

這裏是我的JRXML文件:

<?xml version="1.0" encoding="UTF-8"?> 
<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="Payslip" pageWidth="1000" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="960" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> 
    <import value="org.joda.time.DateTime"/> 
    <style name="Headings" vAlign="Middle" lineSpacing="1_1_2" fontName="Arial" fontSize="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/> 
    <style name="Data" isDefault="true" vAlign="Middle" lineSpacing="1_1_2" fontName="Arial" fontSize="11"/> 
    <parameter name="rptName" class="java.lang.String" isForPrompting="false"/> 
    <parameter name="company" class="java.lang.String"/> 
    <field name="empName" class="java.lang.String"/> 
    <field name="salaryMonthName" class="java.lang.String"/> 
    <field name="salaryMonthYear" class="java.lang.Integer"/> 
    <field name="employeeCode" class="java.lang.String"/> 
    <field name="designation" class="java.lang.String"/> 
    <field name="grade" class="java.lang.String"/> 
    <field name="location" class="java.lang.String"/> 
    <field name="department" class="java.lang.String"/> 
    <field name="branch" class="java.lang.String"/> 
    <field name="dateOfJoining" class="org.joda.time.DateTime"/> 
    <field name="pfNumber" class="java.lang.String"/> 
    <field name="panNumber" class="java.lang.String"/> 
    <field name="bankName" class="java.lang.String"/> 
    <field name="accountNumber" class="java.lang.String"/> 
    <field name="workingDays" class="java.lang.Double"/> 
    <field name="paidDays" class="java.lang.Double"/> 
    <field name="absentDays" class="java.lang.Double"/> 
    <background> 
     <band height="301"> 
      <rectangle> 
       <reportElement mode="Transparent" x="0" y="120" width="324" height="165"/> 
       <graphicElement> 
        <pen lineWidth="2.0"/> 
       </graphicElement> 
      </rectangle> 
      <rectangle> 
       <reportElement mode="Transparent" x="324" y="120" width="320" height="165"/> 
       <graphicElement> 
        <pen lineWidth="2.0"/> 
       </graphicElement> 
      </rectangle> 
     </band> 
    </background> 
    <title> 
     <band height="102"> 
      <line> 
       <reportElement x="0" y="43" width="265" height="1" forecolor="#3333FF"/> 
       <graphicElement> 
        <pen lineWidth="3.0"/> 
       </graphicElement> 
      </line> 
      <textField isStretchWithOverflow="true"> 
       <reportElement x="0" y="0" width="405" height="32" forecolor="#3333FF"/> 
       <textElement lineSpacing="Single"> 
        <font size="16" isBold="true"/> 
       </textElement> 
       <textFieldExpression class="java.lang.String"><![CDATA[$P{company}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="0" y="44" width="200" height="31" forecolor="#3333FF"/> 
       <textElement lineSpacing="Single"> 
        <font fontName="Arial" size="18"/> 
       </textElement> 
       <textFieldExpression class="java.lang.String"><![CDATA[$P{rptName}]]></textFieldExpression> 
      </textField> 
      <textField pattern="EEE, d MMM yyyy HH:mm"> 
       <reportElement mode="Opaque" x="843" y="71" width="117" height="20" forecolor="#FFFFFF" backcolor="#999999"/> 
       <textElement lineSpacing="Single"> 
        <font fontName="Arial"/> 
       </textElement> 
       <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="92" y="82" width="129" height="20"/> 
       <textElement lineSpacing="Single"> 
        <font size="14" isBold="true"/> 
       </textElement> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{salaryMonthName} + " " + $F{salaryMonthYear}]]></textFieldExpression> 
      </textField> 
      <staticText> 
       <reportElement x="0" y="82" width="92" height="20"/> 
       <textElement lineSpacing="Single"> 
        <font size="14" isBold="true"/> 
       </textElement> 
       <text><![CDATA[For Month]]></text> 
      </staticText> 
     </band> 
    </title> 
    <detail> 
     <band height="205"> 
      <staticText> 
       <reportElement style="Headings" x="12" y="23" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Code]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="43" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Name]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="63" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Designation]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="83" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Grade]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="103" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Location]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="123" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Department]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="143" width="91" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Branch]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="12" y="163" width="92" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Date of Joining]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="23" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[P. F. Number]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="43" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[PAN No.]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="63" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Pay Mode/Bank Name]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="83" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[A/C No.]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="103" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Working Days]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="123" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Paid Days]]></text> 
      </staticText> 
      <staticText> 
       <reportElement style="Headings" x="341" y="143" width="98" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <text><![CDATA[Absent Days]]></text> 
      </staticText> 
      <textField> 
       <reportElement x="154" y="23" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{employeeCode}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="43" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{empName}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="63" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{designation}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="83" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{grade}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="103" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{location}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="123" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{department}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="143" width="140" height="20"/> 
       <textElement lineSpacing="Single"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{branch}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="23" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{pfNumber}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="43" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{panNumber}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="63" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{bankName}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="83" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{accountNumber}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="103" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.Double"><![CDATA[$F{workingDays}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="123" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.Double"><![CDATA[$F{paidDays}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="492" y="143" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.Double"><![CDATA[$F{absentDays}]]></textFieldExpression> 
      </textField> 
      <textField> 
       <reportElement x="154" y="163" width="140" height="20"/> 
       <textElement lineSpacing="1_1_2"/> 
       <textFieldExpression class="java.lang.String"><![CDATA[$F{dateOfJoining}.toString("dd-MMM-yyyy")]]></textFieldExpression> 
      </textField> 
      <break> 
       <reportElement x="0" y="184" width="960" height="1"/> 
      </break> 
     </band> 
    </detail> 
</jasperReport> 

回答

5

,您有可能是由於這樣的事實,你不能有HTML對象重疊的問題。我之前和Jasper有過這個問題。如果兩個對象(或更多)重疊,則只有其中一個對象會顯示在報告上。

您可以嘗試使用不重疊任何其他對象的單獨行。

我一直有這個問題,所以我處理類似情況下的情況是使用文本字段的邊框來組成矩形。對於左上角的標籤(代碼),您可以使用它的頂部和左側邊框。對於中間標籤,左邊框。對於底部字段(加入日期),底部和左邊界。然後相反的文本字段。然後,您可以在文本字段上使用填充使其看起來正確。有時我有20或更多的填充以獲得我期待的效果。

我希望這會有所幫助。

+3

爲了使重疊的元素更容易被發現:Options> JasperReports Properties> select net.sf.jasperreports.allow.element.overlap>點擊'Modify property'按鈕>設置爲false。現在嘗試預覽,iReport會在生成報告之前通知您重疊的屬性。 – Weezle

+0

@你是對的,但有沒有辦法輕鬆完成這個iReport 5.6? –

+0

net.sf.jasperreports.allow.element.overlap屬性的默認值是什麼?在我的pc中,它是真的。我將它重置爲false。但之後我無法將其重置爲「true」。我成功設置爲「真」。不知道原因?如果有人知道原因,請解釋。所有其他屬性都只能設置爲小寫。 – SwR