框架的拆分类型 [英] Split type for frame
问题描述
您好我是Jasper报告的新手,我正在报告一个文本字段和相应的子报告在详细信息带下的框架中。现在我需要应用拆分类型以防止细节带,但我无法'因为我在详细的band中有子报告。请帮助我。提前谢谢。
Hi I am new to Jasper report and I am having a report with one text field and corresponding sub-report in the frame under detail band.Now I need to apply split type to prevent for the detail band, but I couldn't because I have subreport within detail band.Please assist me on this.Thanks in advance.
<detail>
<band height="30">
<frame>
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="500" height="30" backcolor="#333333"/>
<box>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#9B64C8"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#9B64C8"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#9B64C8"/>
</box>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="166" height="30" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#000000" backcolor="#FFFFFF">
</reportElement>
<box leftPadding="5">
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#9BA66D"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#9BA66D"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#9BA66D"/>
<rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#9BA66D"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font fontName="Helvetica" size="9" isBold="false" pdfFontName="Helvetica" pdfEncoding="CP1252" isPdfEmbedded="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{text1}]]></textFieldExpression>
</textField>
<subreport>
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="0" height="30"/>
<dataSourceExpression><![CDATA[$F{subreport}]]></dataSourceExpression>
<subreportExpression class="java.lang.String"><![CDATA["sub.jasper"]]></subreportExpression>
</subreport>
</frame>
</band>
</detail>
第二期:
Second issue:
推荐答案
由于 textField
需要 子报告
旁边,您需要jasper报告才能尝试在1页上完整打印记录。
Since the textField
needs to be next to subreport
and you need jasper report to try to print the record completely on 1 page.
- 正确设计报表(移动子报表并给出正确的尺寸)
<subreport>
<reportElement stretchType="RelativeToTallestObject" x="166" y="0" width="334" height="30" uuid="e812a308-674c-41dc-be83-e872752c8d6d"/>
<dataSourceExpression><![CDATA[$F{subreport}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{absolutePath} + "sub.jasper"]]></subreportExpression>
</subreport>
子报表应具有正确的pageWidth,columnWidth和margin
The subreport should have correct pageWidth, columnWidth and margins
<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="subreport" pageWidth="334" pageHeight="842" columnWidth="332" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="775a7e35-9af8-4206-a155-b05a478c35b0">
- 移动
splitType =阻止
从子报告到主报告。
- Move the
splitType="prevent"
from subreport to main report.
这需要您的数据源是 JRRewindableDataSource ,因为jasper报告将尝试填充当前页面中的band ,但如果它不能,它将需要倒回并填写下一页。您需要在数据源中实现 moveFirst()
方法。
This will need that your datasource is a JRRewindableDataSource, since jasper report will try to fill band in current page, but if it can not it will need to rewind and fill on next page. You need to implement the moveFirst()
method in your datasource.
这篇关于框架的拆分类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!