问题
I have a jasper-report that has several subreports. Most of them work fine, but for some reason one of my subreports does not split if it becomes long enough to reach the end of the page, instead it jumps back up to the top of its detail section and continues writing there, overwriting the previous text. I can't see any difference between this subreport and the one that work right. Currently my project uses jasper-reports 1.2.5, but I tried upgrading to 4.0.1 (just for this one report) and the results were the same.
This is the section of jrxml where my subreport which doesn't work is included:
<subreport isUsingCache="true">
<reportElement
x="0"
y="172"
width="468"
height="21"
key="subreport-3"
positionType="Float"/>
<dataSourceExpression><![CDATA[$P{dataSourcePreviousYukonLicence}]]></dataSourceExpression>
<subreportExpression class="java.io.InputStream"><![CDATA[this.getClass().getResourceAsStream("/config/template/subreportPreviousYukonLicence2.jasper")]]></subreportExpression>
And this is the section for one that does work:
<subreport isUsingCache="true">
<reportElement
x="0"
y="43"
width="468"
height="21"
key="subreport-2"
positionType="Float"/>
<dataSourceExpression><![CDATA[$P{dataSourceConvictionHistory}]]></dataSourceExpression>
<subreportExpression class="java.io.InputStream"><![CDATA[this.getClass().getResourceAsStream("/config/template/subreportConvictionHistory.jasper")]]></subreportExpression>
The subreports themselves are very similarly designed, with all the bands having is isSplitAllowed="true"
, and they ues the same fonts and the same types of report elements.
If anyone has any ideas why one would split properly and the other not, your help woulb be much appreciated.
回答1:
We had the same or at least extremely similar problem. The cause wasn't in the report, but in the definition of the subreport. It was configured to have multiple columns and when it reached the last line of the report it startet again on the top in the second column.
Setting it to single column fixed that. The following is the simplified delta in our case
-<jasperReport ... columnCount="3" pageWidth="240" pageHeight="555" ...>
+<jasperReport ... pageWidth="240" pageHeight="555" ...>
Now the band starts on the next page if the subreport doesn't fit on the current page.
来源:https://stackoverflow.com/questions/6272367/jasperreports-subreport-not-splitting