问题描述
我有一个主报告,其中包含很多信息,我需要添加一个子报告.当我运行主报表的JUnit测试时,会引发异常:
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?
推荐答案
仅当将子报表放在标题"区域或页面标题"区域时,才会发生这种情况.因此,请将您的子报告放置在上述频段之外,因为该频段是非循环频段.
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.
这篇关于Jasper Report子报表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!