Jasper reports 不显示矩形边框

Jasper reports 不显示矩形边框,jasper-reports,Jasper Reports,我有一个要求,我需要显示一段由边框包围的数据,如下所示: 我尝试过在背景带中添加矩形组件。在“内部预览”窗口和“PDF预览”中,它显示如上所示,但当我在服务器中运行它或使用HTML预览时,边框将消失。我还尝试在细节栏中插入矩形组件,并在数据周围使用框架而不是矩形,但存在相同的问题 我正在使用iReport 5.0.1,兼容性设置为JasperReports 3.5.1 以下是我的jrxml文件: <?xml version="1.0" encoding="UTF-8"?> <

我有一个要求,我需要显示一段由边框包围的数据,如下所示:

我尝试过在背景带中添加矩形组件。在“内部预览”窗口和“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>

您遇到的问题可能是由于您不能让对象在HTML中重叠。我以前和贾斯珀有过这个问题。如果两个(或多个)对象重叠,则报告中将只显示其中一个对象

您可以尝试使用不与任何其他对象重叠的单独线

我很难做到这一点,所以在像你这样的情况下,我处理这种情况的方法是使用文本字段的边框来组成矩形。对于左上标签(代码),可以使用其左上边框。对于中间标签,显示左边框。对于底部字段(连接日期),显示底部和左侧边框。文本字段则相反。然后可以在文本字段上使用填充,使其看起来正确。有时我会用20或更多的填充物来达到我想要的效果


我希望这会有所帮助。

要使重叠元素更容易发现:选项>JasperReports属性>选择net.sf.JasperReports.allow.element.overlap>单击“修改属性”按钮>设置为false。现在尝试预览,iReport将在生成报告之前通知您重叠属性。@Tom您是对的,但是对于iReport 5.6,有什么方法可以轻松做到这一点吗?net.sf.jasperreports.allow.element.overlap属性的默认值是多少?在我的电脑中是真的。我将其重置为false。但之后,我无法将其重置为“true”。我成功设置为“true”。不知道原因吗?如果有人知道原因,请解释。所有其他属性仅以小写字母设置。