框架分体式
Split type for frame
你好,我是 Jasper 报告的新手,我有一份报告,其中包含一个文本字段和框架中的相应子报告,在详细信息下 band.Now 我需要应用拆分类型来防止详细信息带,但我做不到,因为我有详细的子报告 band.Please 提前 this.Thanks 协助我。
<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>
第二期:
因为 textField
需要 紧挨着 subreport
并且您需要 jasper 报告来尝试将记录完整地打印在一页上。
- 正确设计报表(移动子报表并赋予它正确的维度)
<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 和 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="prevent"
从子报表移动到主报表。
这需要您的数据源是 JRRewindableDataSource,因为 jasper 报告会尝试填充当前页面中的区域,但如果不能,则需要倒带并在下一页填充。您需要在数据源中实现 moveFirst()
方法。
你好,我是 Jasper 报告的新手,我有一份报告,其中包含一个文本字段和框架中的相应子报告,在详细信息下 band.Now 我需要应用拆分类型来防止详细信息带,但我做不到,因为我有详细的子报告 band.Please 提前 this.Thanks 协助我。
<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>
第二期:
因为 textField
需要 紧挨着 subreport
并且您需要 jasper 报告来尝试将记录完整地打印在一页上。
- 正确设计报表(移动子报表并赋予它正确的维度)
<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 和 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="prevent"
从子报表移动到主报表。
这需要您的数据源是 JRRewindableDataSource,因为 jasper 报告会尝试填充当前页面中的区域,但如果不能,则需要倒带并在下一页填充。您需要在数据源中实现 moveFirst()
方法。