2013-04-16 95 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