Jasper Report子报表问题

发布于 2024-10-19 12:25:27 字数 3865 浏览 1 评论 0原文

我有一个包含大量信息的主报告,我需要添加一个子报告。当我运行Master Report的JUnit Test时,抛出异常:

net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: The subreport is placed on a non-splitting band, but it does not have a rewindable data source.
    at net.sf.jasperreports.components.table.fill.FillTable.rewind(FillTable.java:392)
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.rewind(JRFillComponentElement.java:171)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.rewind(JRFillElementContainer.java:651)
    at net.sf.jasperreports.engine.fill.JRFillBand.refill(JRFillBand.java:355)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:864)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at ar.com.qyttrade.jasperreports.ExtraMainReportTest.extraReportTest(ExtraMainReportTest.java:95)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: net.sf.jasperreports.engine.JRException: The subreport is placed on a non-splitting band, but it does not have a rewindable data source.
    at net.sf.jasperreports.engine.fill.JRFillSubreport.rewind(JRFillSubreport.java:782)
    at net.sf.jasperreports.components.table.fill.FillTable.rewind(FillTable.java:388)
    ... 35 more

我不知道这个错误的目的是什么。我在细节带中尝试了“分割类型”和“允许分割”的每种组合,但它不起作用。我需要知道为什么会发生这个错误。 另一个问题是在子报告中我有一个带有自己的数据源的表,如何设置主报告的参数以及子报告应如何加载此数据源?

I have a master report which contains a lot of information and I need to add a Sub-Report. When I run JUnit Test of Master Report, an exception is thrown:

net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: The subreport is placed on a non-splitting band, but it does not have a rewindable data source.
    at net.sf.jasperreports.components.table.fill.FillTable.rewind(FillTable.java:392)
    at net.sf.jasperreports.engine.fill.JRFillComponentElement.rewind(JRFillComponentElement.java:171)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.rewind(JRFillElementContainer.java:651)
    at net.sf.jasperreports.engine.fill.JRFillBand.refill(JRFillBand.java:355)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2044)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:864)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at ar.com.qyttrade.jasperreports.ExtraMainReportTest.extraReportTest(ExtraMainReportTest.java:95)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: net.sf.jasperreports.engine.JRException: The subreport is placed on a non-splitting band, but it does not have a rewindable data source.
    at net.sf.jasperreports.engine.fill.JRFillSubreport.rewind(JRFillSubreport.java:782)
    at net.sf.jasperreports.components.table.fill.FillTable.rewind(FillTable.java:388)
    ... 35 more

I don't know what is the purpose of this error. I tried every combination with "Split type" and "Split Allowed" at Detail Band, but it does not work. I need to know why this error is done.
Another issue is in the sub-report I have a table with it own Data Source, how set the parameters to Master Report and how the sub report should load this Data Source?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼前雾蒙蒙 2024-10-26 12:25:27

您可能需要检查是否根本没有重叠的元素。当元素重叠哪怕是一个像素时,Jasper 可能会非常挑剔。当我遇到这样的情况时,我通常会保存我的报告,然后开始一次删除一个元素。

从您的帖子中尚不清楚,但是如果两个报告在主报告中没有子报告的情况下运行,它们是否可以独立工作。这是我要测试的第一件事。我对这里可能发生的具体情况的猜测是,您有一个小区域,子报告放置在主报告中。然后主报表要求子报表跨页拆分,而子报表无法做到这一点。如果是这种情况,请将子报表设置为可以单独测试它的状态,并将其拆分到页面上的不同区域。

You may want to check that there are no overlapping elements at all. Jasper can be very very finicky when you have elements overlap by even a single pixel. When I run into situations like this, I usually save my report, then start removing one element at a time.

It wasn't clear from your post, but do both reports work independently if they are run without the subreport in the main report. That is the first thing I would test. My guess of what might be happening here specifically is that you have a small area where the sub report is placed in the main report. The main report then asks the subreport to split across pages, which the subreport is unable to do. If this is the case, get the subreport into a state where you can test it on its own and split it in different areas across the page.

入怼 2024-10-26 12:25:27

使用 iReport 设计和创建 Jasper 报告会容易得多。 iReport 直观地显示带区和组件的位置,因此您几乎永远不会陷入重叠问题的情况。您可以从工具箱中拖放。这与使用 Matisse 进行 Swing 非常相似。

It would be a lot easier for you to design and create your Jasper reports with iReport. iReport shows visually the location of your bands and components, so you can practically never get stuck in situations of overlapping problems. You can drag and drop from a toolbox. It is pretty much like using Matisse for Swing.

睫毛溺水了 2024-10-26 12:25:27

仅当您将子报表放置在标题区域或页眉区域时才会发生这种情况。
因此,请将子报告放置在除上述带之外的位置,因为该带是非循环带。

This is only happen when you Placed your subreport on Title band or Page Header band.
So Place your sub report except above band because this bands are non looping bands.

前事休说 2024-10-26 12:25:27

就我而言,我使用的是类型的自定义数据源

public class BeanListDs implements JRDataSource {
    ...

    @Override
    public boolean next() throws JRException {
        ...
    }

    @Override
    public Object getFieldValue(JRField jrField) throws JRException {
        ...     
    }
}

,但在某些情况下报表渲染引擎需要 JRRewindableDataSource 类型的数据源,

public class BeanListDs implements JRRewindableDataSource {
    ...

    @Override
    public boolean next() throws JRException {
        ...
        return true;
    }

    @Override
    public Object getFieldValue(JRField jrField) throws JRException {
        ...     
    }

    @Override
    public void moveFirst() throws JRException {
        ...
    }
}

这解决了问题。

In my case I was using a custom datasource of type

public class BeanListDs implements JRDataSource {
    ...

    @Override
    public boolean next() throws JRException {
        ...
    }

    @Override
    public Object getFieldValue(JRField jrField) throws JRException {
        ...     
    }
}

but the report rendering engine in some cases requires a datasource of type JRRewindableDataSource instead

public class BeanListDs implements JRRewindableDataSource {
    ...

    @Override
    public boolean next() throws JRException {
        ...
        return true;
    }

    @Override
    public Object getFieldValue(JRField jrField) throws JRException {
        ...     
    }

    @Override
    public void moveFirst() throws JRException {
        ...
    }
}

this fixed the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文