3
votes

I am attempting to split my report into multiple Excel sheets when I export from Jasperserver.

Report Structure - Main page with four subreports. A group header and footer for each subreport, the header contains the subreport element while in the footer I have placed page break elements with the property..

<property name="net.sf.jasperreports.export.xls.break.after.row" value="true"/> 

Placing the Pbreaks in the header/footer doesn't seem to make a difference and each subreport has ignore pagination checked (true).

The main report has this property,

<property name="net.sf.jasperreports.export.xls.one.page.per.sheet" value="true"/>

I have read through similar questions on here and have not been able to produce any results with many different combinations. Not sure if my problem is specific to Ireport 5.0.

EDIT: Per Zoran's suggestion, I got the report working! (now if only it wouldn't run out of memory) Here's the XML behind the text field.

<textField>
<reportElement uuid="73dc8dab-6ebf-4f47-bf8c-a1ab6b4b0454" x="0" y="0" width="100" height="1">
<property name="net.sf.jasperreports.export.xls.break.after.row" value="true"/>
</reportElement>
<textElement/>
</textField>
1

1 Answers

3
votes

Put the page breaks into the main report. I had the same problem with subreports and tried every possible property combination but it seems impossible to break a page from subreport.

EDIT: It stopped working on my report also and I solved by adding 1px high text field with property net.sf.jasperreports.export.xls.break.after.row set to true. I also use this field to set sheet names using net.sf.jasperreports.export.xls.sheet.name

I didn't receive notification for your response otherwise I would answer sooner...

FIELD SOURCE

<textField>
    <reportElement positionType="FixRelativeToBottom" x="1325" y="122" width="1" height="1" uuid="cbee8af0-8639-4f97-bd6a-4cd284e604c4">
        <property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
        <propertyExpression name="net.sf.jasperreports.export.xls.break.after.row"><![CDATA[$V{REPORT_COUNT} < $F{MAX_ROW_CNT} ? "true" : "false"]]></propertyExpression>
        <propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$F{GROUP_NAME}]]></propertyExpression>
    </reportElement>
    <textFieldExpression><![CDATA[($V{REPORT_COUNT} < $F{MAX_ROW_CNT}) ? "true" : "false"]]></textFieldExpression>
</textField>

Field is under the sub-report element on the right edge of the report. I'm using expression for page break to avoid extra empty page at the end of the report. Field MAX_ROW_CNT is from analytical function in query and REPORT_COUNT is JR variable indicating current row number.