Hintergrund: Jaspersoft Studio 6.Jasper Bericht entfernen/auszublenden leere Gruppe
Lassen Sie sich diese Kreuztabellen-:
Der Datensatz für die Kreuztabelle:
select 'prod1' as prod, 'mon1' as month, 1 as val
union all select 'prod1' as prod, 'mon2' as month, 1 as val
union all select 'prod2' as prod, 'mon1' as month, 1 as val
union all select 'prod2' as prod, 'mon2' as month, 1 as val
union all select 'prod3' as prod, null as month, null as val
Das Problem: wie Sie haben vielleicht bemerkt, prod3 hat keine Daten zu mon1 oder mon2. Aber ich werde es immer noch brauchen, um in dem Bericht gezeigt zu werden. Es gibt also die Null-Spalte, die von Jasper erstellt wurde. Wie kann ich die Nullspalte loswerden? Ich habe versucht, leer, wenn Null oder Zeile entfernen, wenn an verschiedenen Stellen leer, aber nichts funktioniert. Sogar an einem gewissen Punkt kann ich den Nulltext loswerden, aber die Zelle wird immer noch gerendert, so dass die Ränder und Hintergrundfarben immer noch angezeigt werden.
Und die Quelldatei (nur ein Kreuztabellen- mit einer Zeilengruppe und einer Spaltengruppe):
<?xml version="1.0" encoding="UTF-8"?>
<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="test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d00fbad1-be1e-4544-b22f-6dca803b6714">
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#005FB3">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<queryString>
<![CDATA[select 'prod1' as prod, 'mon1' as month, 1 as val
union all select 'prod1' as prod, 'mon2' as month, 1 as val
union all select 'prod2' as prod, 'mon1' as month, 1 as val
union all select 'prod2' as prod, 'mon2' as month, 1 as val
union all select 'prod3' as prod, null as month, null as val]]>
</queryString>
<field name="prod" class="java.lang.String"/>
<field name="month" class="java.lang.String"/>
<field name="val" class="java.lang.Integer"/>
<summary>
<band height="229" splitType="Stretch">
<crosstab ignoreWidth="true">
<reportElement x="10" y="14" width="520" height="116" isRemoveLineWhenBlank="true" uuid="bb1bb352-1dab-438b-b2c8-b73286af3a9c">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
</reportElement>
<rowGroup name="prod1" width="60">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{prod}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="d56c7426-8030-4919-8869-86129c230a48"/>
<textFieldExpression><![CDATA[$V{prod1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="ef3d9aab-f696-48c4-b95b-6be099951c55"/>
<text><![CDATA[Total prod1]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="month1" height="20">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{month}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField isBlankWhenNull="false">
<reportElement x="0" y="0" width="60" height="20" uuid="f8dca50f-1f98-425b-bc4e-8a9505901477"/>
<textFieldExpression><![CDATA[$V{month1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="4960b0b9-4df7-4216-908e-e042ccf2e3a6"/>
<text><![CDATA[Total month1]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="val_MEASURE1" class="java.lang.Integer" calculation="Sum">
<measureExpression><![CDATA[$F{val}]]></measureExpression>
</measure>
<crosstabCell width="60" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField isBlankWhenNull="false">
<reportElement x="0" y="0" width="60" height="20" uuid="d207dcd9-1db6-4adb-a7ba-1b539fa06993"/>
<textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="month1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="59ff8664-202c-4ec7-966c-93c30b372202"/>
<textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="prod1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="686e7851-9a94-4cbe-aac1-60703fdfc049"/>
<textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="prod1" columnTotalGroup="month1">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="acbe85bf-5cea-40d3-9951-cb0de8baa353"/>
<textFieldExpression><![CDATA[$V{val_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>
was ist filter out in SQL oder Java-Ebene? –
Was meinst du? Ich möchte prod3 nicht herausfiltern, ich möchte, dass es im Bericht steht, zeigt nur 0 für mon1 und mon2. – thotwielder