我有一个Jasper报告,其中包含标题和详细信息。当报告中包含详细信息时,将显示标题。但是,当报告中没有详细信息时,标题将不会显示。
我希望标题是固定的,以便无论是否有细节都可以显示。我已经为单独的报告配置了这种方式。这两个报告之间的唯一区别是,第二个报告(具有固定的标头,无论显示什么内容)均不使用框架,而此报告(有问题的报告)确实使用框架。
这是我有问题的报告的标题部分的XML,它没有显示固定的标题。
有人知道为什么在没有报告详细信息的情况下标题不显示吗?毕竟,我确实使用静态文本。我不确定为什么静态文本不显示。
<title>
<band height="60" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<frame>
<reportElement style="Title" mode="Opaque" x="0" y="0" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="f5eeff7b-82c8-4e5e-b89f-c8f4e0bf230e">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
</box>
<staticText>
<reportElement x="332" y="0" width="134" height="20" uuid="ff17f385-30ec-417d-bf55-2f79996f0ca9">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Sign Audit Report]]></text>
</staticText>
</frame>
<frame>
<reportElement mode="Opaque" x="0" y="20" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="f9c0304d-0864-46b3-8b18-b28b20d8c7de">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
<topPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
<rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#666666"/>
</box>
<textField>
<reportElement x="299" y="0" width="190" height="19" uuid="ace3db7b-5c61-4205-98e9-872483bc9206"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$P{STORE_ID} +" - "+$P{STORE_NAME}]]></textFieldExpression>
</textField>
</frame>
<frame>
<reportElement mode="Opaque" x="0" y="40" width="800" height="20" forecolor="#000000" backcolor="#FFFFFF" uuid="b0c895f6-6dbd-477d-9858-9ad66af087e1">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<box padding="1">
<pen lineWidth="0.5" lineColor="#666666"/>
</box>
<staticText>
<reportElement x="0" y="0" width="99" height="20" uuid="d37d9a5e-2dad-4774-8b62-87a458b25902">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="10"/>
</textElement>
<text><![CDATA[Report generated on :]]></text>
</staticText>
<textField pattern="MM/dd/yyyy">
<reportElement x="99" y="0" width="122" height="20" uuid="e4e59db3-b1d7-4f84-8052-96d6c4ea34a1">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format(new Date())]]></textFieldExpression>
</textField>
<textField pattern="MM/dd/yyyy">
<reportElement x="641" y="0" width="150" height="20" uuid="98a8efa4-19ae-4d06-8874-12482bd8aeb1">
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format($P{effStartDate})+" - "+new java.text.SimpleDateFormat($P{DATE_FORMAT_PARAM}).format($P{endDate})]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="579" y="0" width="64" height="20" uuid="6dfe0bf6-cd90-48b2-9cc9-7bad865a9c66">
<property name="com.jaspersoft.studio.unit.x" value="pixel"/>
<property name="com.jaspersoft.studio.unit.y" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="10"/>
</textElement>
<text><![CDATA[Signs Active :]]></text>
</staticText>
</frame>
</band>
</title>
答案 0 :(得分:0)
在没有可用数据时如何呈现报告取决于碧玉报告标签上的whenNoDataType属性。
要在JasperSoft Studio中进行设置,请选择大纲中的顶部节点,然后选择适当的“无数据类型时”(在您的情况下为“所有节无详细信息”)
jrxml变为:
<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="Blank_A4_1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
.....
</jasperReport>
请参见whenNoDataType="AllSectionsNoDetail"
属性