Jasper reports 设置具有标题和详细信息栏的jasper子报表的边框

Jasper reports 设置具有标题和详细信息栏的jasper子报表的边框,jasper-reports,border,dynamic-jasper,Jasper Reports,Border,Dynamic Jasper,我正在从事一个grails项目,该项目使用jasper插件下载pdf和doc格式的文档 我有几个jasper子报告,并使用动态jasper中的这些子报告下载pdf和docx格式的文档。我使用动态jasper报表,因为jasper子报表的位置可能会有所不同 我的jasper子报告有一个标题和一个细节栏 输出为 现在我的问题是边界。需要一个边界,如: 我试图设置矩形,但都失败了,因为两个乐队并没有共享一个腭(组成部分) 我的要求是通过jasper report或动态jasper设置边框。我不知

我正在从事一个grails项目,该项目使用jasper插件下载pdf和doc格式的文档

我有几个jasper子报告,并使用动态jasper中的这些子报告下载pdf和docx格式的文档。我使用动态jasper报表,因为jasper子报表的位置可能会有所不同

我的jasper子报告有一个标题和一个细节栏

输出为

现在我的问题是边界。需要一个边界,如:

我试图设置矩形,但都失败了,因为两个乐队并没有共享一个腭(组成部分)

我的要求是通过jasper report或动态jasper设置边框。我不知道如何设置边框

编辑

我还尝试通过动态jasper代码使用边框和矩形设置边框,输出为:

框架和矩形未覆盖整个子报表。这是我的密码:

JRDesignRectangle rectangle = new JRDesignRectangle();
//JRDesignFrame rectangle = new JRDesignFrame();
rectangle.setX(subReport.getX());
rectangle.setY(subReport.getY());
rectangle.setHeight(subReport.getHeight());
rectangle.setWidth(subReport.getWidth());
rectangle.setPositionType(PositionTypeEnum.FLOAT);
band.addElement(rectangle);

如果您使用的是jasper report插件,那么可以打开JRXML文件并说

 <box>
        <topPen lineWidth="1.0"/>
        <leftPen lineWidth="1.0"/>
        <bottomPen lineWidth="1.0"/>
        <rightPen lineWidth="1.0"/>
    </box>
子报表源代码

<?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="testborder" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="421" splitType="Stretch">
            <subreport>
                <reportElement x="25" y="148" width="200" height="100"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                <subreportExpression><![CDATA["C:\\jaspersamples\\testborder_subreport1.jasper"]]></subreportExpression>
            </subreport>
            <frame>
                <reportElement x="45" y="119" width="390" height="176"/>
                <box>
<topPen lineWidth="2.0" lineStyle="Solid"/>
<leftPen lineWidth="2.0" lineStyle="Solid"/>

                    <bottomPen lineWidth="2.0" lineStyle="Solid"/>
                    <rightPen lineWidth="2.0" lineStyle="Solid"/>
                </box>
            </frame>
        </band>
    </detail>
</jasperReport>
<?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="testborder_subreport1" language="groovy" pageWidth="802" pageHeight="555" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="802" 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="0"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <pageHeader>
        <band height="29" splitType="Stretch">
            <staticText>
                <reportElement x="317" y="5" width="100" height="20"/>
                <textElement/>
                <text><![CDATA[HELLO TEST]]></text>
            </staticText>
        </band>
    </pageHeader>
    <summary>
        <band height="29" splitType="Stretch">
            <staticText>
                <reportElement x="317" y="0" width="100" height="20"/>
                <textElement/>
                <text><![CDATA[i am testing BORDER]]></text>
            </staticText>
        </band>
    </summary>
</jasperReport>

输出有点像这样


您可以使用IReport或Jaspersoft Studio将子报告放入一个框架中。 雅思软件工作室的步骤如下:

  • 选择主报告并打开大纲视图
  • 找到子报表元素并右键单击它
  • 选择“封闭到框架中”
  • 打开框架元素的属性
  • 转到“边框”选项卡并选择所需的边框选项

  • 您提供的代码在组件周围创建一个框,并使用框架和矩形链接子报表。但在我的sureport中,我有标题和细节栏,而框架和矩形不能同时覆盖这两个栏,因为组件不能跨越栏边界。我编辑了我的文章,请看一下。嗨,我尝试了一个有摘要栏和标题栏的子报告样本,并把它放在框架中,它能够画出它周围的边框。我正在编辑问题以发布子报表和主报表的代码。我已经尝试了您的代码,它非常好。但是,当我用我的子报告替换您的子报告时,即使不显示静态内容,下载时也只会显示一个框。选择框架时,右键单击打开对话框菜单栏,并有一个选项“发送回”,单击该按钮,现在所有子报表都将位于前面并向后显示。我按照您的建议执行了操作,但结果相同。我正在向子报表发送动态数据,可能是我在那里做错了什么。我只是将我的子报表放在您提供的主报表中,是否有任何特殊的方法将字段和参数从主报表传递到子报表。