当前位置: 首页 > 知识库问答 >
问题:

无法用Jasper制作子报告

罗祺
2023-03-14

我正在使用Jaspersoft studio创建报告。我在我的Jasper主报告中有一个子报告。问题是,我无法做到这一点,因为如果我将子报告添加到主报告的< code>Detail band中,子报告会生成多次,有时是逐行生成,有时是整个子报告在若干页中重复。出于同样的原因,我不能把它放在< code > summer Band 中。

我无法将其放入列页脚带或其他页脚中,因为它显示以下错误

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: Subreport overflowed on a band that does not support overflow.
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:467)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:442)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:334)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: Subreport overflowed on a band that does not support overflow.
    at net.sf.jasperreports.engine.fill.FillerSubreportParent.addPage(FillerSubreportParent.java:113)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.addPageToParent(JRBaseFiller.java:1213)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.addPage(JRVerticalFiller.java:1836)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageBreak(JRVerticalFiller.java:1919)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBreak(JRVerticalFiller.java:1948)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:730)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:264)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:124)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:540)
    at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:393)
    at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:704)
    at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
    at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

由于以下错误,我无法将其放入页首,否则它将继续执行。

net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.fillReport(ReportControler.java:467)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler.access$18(ReportControler.java:442)
    at com.jaspersoft.studio.editor.preview.view.control.ReportControler$4.run(ReportControler.java:334)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillPageHeader(JRVerticalFiller.java:415)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:258)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:124)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:540)
    at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:120)
    at java.lang.Thread.run(Unknown Source)

以下是我主要报告的代码

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2014-12-16T11:26:41 -->
<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="Portfolio_View_Report" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="961f2f5f-8ed1-422c-9a1a-6b9dcdf1624f">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="xxx"/>
    <parameter name="idPortfolio" class="java.lang.Integer"/>
    <queryString>
        <![CDATA[SELECT * FROM Client]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="119" splitType="Stretch">
            <property name="local_mesure_unitheight" value="pixel"/>
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <image>
                <reportElement x="210" y="1" width="140" height="76" uuid="f5d606fc-24d8-4536-9c35-56ce81c863c2"/>
                <imageExpression><![CDATA["C:/Users/xxx/JaspersoftWorkspace/xxx/xxx.png"]]></imageExpression>
            </image>
            <staticText>
                <reportElement x="0" y="80" width="210" height="30" uuid="8c8eb2f8-9d3d-46a0-9d4c-0d049e8c544d"/>
                <textElement>
                    <font fontName="Times New Roman" size="14" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Portfolio View Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="159" splitType="Stretch">
            <staticText>
                <reportElement x="-1" y="0" width="163" height="20" uuid="8ffdf975-7965-4402-b9af-ef7785872f24"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="Times New Roman"/>
                </textElement>
                <text><![CDATA[Generated By: xxx]]></text>
            </staticText>
            <textField pattern="dd-MM-yyyy">
                <reportElement x="450" y="0" width="100" height="20" uuid="cfd44de8-bc3d-4a2d-9f53-b9fdb969b061"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
            </textField>
            <subreport runToBottom="true">
                <reportElement stretchType="RelativeToTallestObject" x="0" y="55" width="555" height="60" uuid="a99b1643-200b-4d7c-ade2-26e30b4fcc82">
                    <property name="local_mesure_unitheight" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                </reportElement>
                <subreportParameter name="idPortfolio">
                    <subreportParameterExpression><![CDATA[$P{idPortfolio}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA["Transactions_Report.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </pageHeader>
    <detail>
        <band height="36" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
        </band>
    </detail>
    <columnFooter>
        <band height="285" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
        </band>
    </columnFooter>
    <pageFooter>
        <band height="120" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="100" splitType="Stretch"/>
    </summary>
</jasperReport>

下面是我的子报告的代码

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.0.0.final using JasperReports Library version 6.0.0  -->
<!-- 2014-12-16T11:28:26 -->
<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="Transactions_Report" pageWidth="500" pageHeight="842" columnWidth="500" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="4204d16c-e22f-46a2-b4c5-8be93fa35bc4">
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="xxx"/>
    <parameter name="idPortfolio" class="java.lang.Integer"/>
    <queryString language="SQL">
        <![CDATA[SELECT Transactions.`idTransactions`,
Transactions.`Transaction_TimeStamp`,
Transactions.`idPortfolio`,
CASE when Transactions.`Transaction_Amount` <= 0 
     THEN NULL 
     else Transaction_Amount
END AS Encashments,
CASE when Transactions.`Transaction_Amount` > 0 
     THEN NULL 
     else (Transactions.`Transaction_Amount`*-1)
END AS Additions,
Portfolio.Activation 
FROM Transactions 
INNER JOIN Portfolio ON Transactions.idPortfolio = Portfolio.idPortfolio 
WHERE Transactions.idPortfolio= $P{idPortfolio} 
ORDER BY `Transaction_TimeStamp` DESC]]>
    </queryString>
    <field name="Transaction_TimeStamp" class="java.sql.Date">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <field name="Additions" class="java.lang.Double"/>
    <field name="Encashments" class="java.lang.Double"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="47" splitType="Stretch">
            <staticText>
                <reportElement x="5" y="10" width="180" height="30" uuid="30e059fd-caed-4e67-a4f6-d06f2897ac59"/>
                <textElement>
                    <font fontName="Times New Roman" size="14" isBold="true" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Transations]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="44" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="160" height="30" uuid="344e0833-c92a-47bf-bece-162b5ac7e52b">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <text><![CDATA[Date]]></text>
            </staticText>
            <staticText>
                <reportElement x="166" y="0" width="160" height="30" uuid="9bf82277-53b7-4244-aae9-84cf310e6d94">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <text><![CDATA[Additions]]></text>
            </staticText>
            <rectangle>
                <reportElement x="0" y="30" width="490" height="1" uuid="45244617-f10e-4867-bc84-71aa0c42649b"/>
                <graphicElement>
                    <pen lineWidth="0.5"/>
                </graphicElement>
            </rectangle>
            <staticText>
                <reportElement x="330" y="0" width="160" height="30" uuid="68c554b4-0d79-4236-9e3f-db1b5dd19f7f">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <text><![CDATA[Encashments]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="40" splitType="Stretch">
            <textField pattern="dd-MM-yyyy">
                <reportElement x="2" y="10" width="158" height="30" uuid="e2ab3765-dd44-4f8d-aedb-d411cce30384">
                    <property name="local_mesure_unitwidth" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$F{Transaction_TimeStamp}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="166" y="10" width="160" height="30" uuid="bb3baa95-bf15-4462-bb59-3461b1f4e1c7">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$F{Additions}]]></textFieldExpression>
            </textField>
            <textField isBlankWhenNull="true">
                <reportElement x="330" y="10" width="160" height="30" uuid="c625f008-1390-4245-8035-9bdc98c21d79">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$F{Encashments}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

这有什么问题?

共有1个答案

龙佐
2023-03-14

我发现,对于我的情况,最好使用表而不是子报表。这就是我所做的。

>

  • 详细信息带中创建表。
  • 创建单独的数据集并将其分配给这些表。
  • 现在,即使我不需要对主报表进行查询,我也必须提供一个以便jasper继续。查询很棘手且有问题,因为如果它返回多个结果,详细带中的项目将重复。因此,由于我需要详细带中的表只打印“一次”,我必须将主报表查询返回的结果限制为一个。我做了如下操作。

    < code >从客户端选择名称,其中idClient=1

    现在细节带中的项目将只执行一次操作。由于细节带中的表包含它们自己的查询,因此整个表将填充预期的结果。

    同样的方法也适用于子报告。

  •  类似资料:
    • 我的应用程序中有几个类似的报告,因此我创建了一个基本结构,在标题中有一个子报告,在页脚中有另一个子报告。 我不知道为什么我找不到解决这个问题的方法,如果有人能帮我...谢谢!

    • 当简单报表不适用于子报表时,此操作有效...

    • 我非常熟悉jasperstudio 6.3.0,并且能够毫无问题地从java运行其他报告。效果很好。但是,我无法运行包含子报表的报表。我在这里找到了stackoverflow的解决方案,但仍然无法使其工作。在我的解决方案中,我将报告加载到一个表中进行存储,并从数据库中提取子报告和主报告,然后编译jrxml。到那时一切都很好 网旧金山。jasperreports。发动机JREException:在以

    • 但是当我移除EmployeeID参数时,我希望移除过滤器。所以所有的结果都应该显示出来。 我的问题是,在sql查询中传递可选where的正确方式是什么。

    • 我正在从. jasper文件加载jasper报告文件以提高性能,如下所示。 但是我现在有一个要求,动态形成的查询必须设置为. jasper(编译)文件。有没有办法做同样的事情?

    • 我是Jasper报告新手,我有一个报告,它只有一个简单脚本,只返回一个字符串。在使用Jasper studio 6.5.0预览时,我能够看到结果,但当我尝试在本地Jasper服务器上部署相同的报表时,它会抛出错误: 我正在Glassfish 4.1.1上运行服务器,在lib文件夹中包含了scriplet jar文件,并根据https://community.jaspersoft.com/wiki/