Jaspersoft: Two column groups next to each other in Crosstab

Viewed 31

Is it possible to have two column groups next to one another in crosstab in Jasper? Is it also possible to have "normal" cells afterwards? I would like to have an report in which there are some columns with regular data ("name", "surname"), followed by two column groups ending with Total ("level - A" and "level - B") column followed by more "normal columns" ("OtherData" and "SomeData"). Please see attached picture to clarify what I mean. Is it even possible to add column group next to one another? The only way to do it I can think of (not yet tested) is to create multiple crosstabs next to each other, but it seems, like a workaround, not a solution.

enter image description here

Every time I try to do it in TIBCO Jaspersoft Studio it adds below the first column group (example jrxml shown below):

<!-- Created with Jaspersoft Studio version 6.19.1.final using JasperReports Library version 6.19.1-867c00bf88cd4d784d404379d6c05e1b419e8a4c  -->
<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="1500" pageHeight="195" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="1500" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isSummaryWithPageHeaderAndFooter="true" isFloatColumnFooter="true" isIgnorePagination="true" uuid="628d33df-ae59-470b-9a74-d7d593aff3d7">
    <property name="net.sf.jasperreports.export.xls.white.page.background" value="false"/>
    <property name="com.jaspersoft.studio.report.description" value=""/>
    <property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
    <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
    <style name="Crosstab Data Text" isDefault="true" hTextAlign="Center" vTextAlign="Middle" fontSize="10"/>
    <parameter name="parameters_json" class="java.lang.String">
        <property name="required" value="true"/>
    </parameter>
    <queryString>
        <![CDATA[select name, 
                        surname, 
                        level_A,
                        level_A_value, 
                        level_B,
                        level_B_value, 
                        from report_generator_service.test_report( $P{parameters_json}::JSONB )]]>
    </queryString>
    <field name="name" class="java.lang.String"/>
    <field name="surname" class="java.lang.String"/>
    <field name="level_A" class="java.lang.Integer"/>
    <field name="level_A_value" class="java.lang.Integer"/>
    <field name="level_B" class="java.lang.Integer"/>
    <field name="level_B_value" class="java.lang.Integer"/>
    <summary>
        <band height="180">
            <elementGroup>
                <crosstab>
                    <reportElement style="Crosstab Data Text" x="0" y="0" width="1500" height="136" isPrintInFirstWholeBand="true" uuid="f94e5a80-a580-4870-b3bc-d0ce5173a3f2">
                        <property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab Data Text"/>
                    </reportElement>
                    <crosstabDataset>
                        <dataset resetType="Report"/>
                    </crosstabDataset>
                    <crosstabHeaderCell>
                        <cellContents>
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                            <staticText>
                                <reportElement style="Crosstab Data Text" x="1" y="0" width="70" height="30" uuid="171453ae-fd63-4161-a08f-89df73994cd0"/>
                                <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                    <pen lineWidth="0.5"/>
                                    <topPen lineWidth="0.5"/>
                                    <leftPen lineWidth="0.5"/>
                                    <bottomPen lineWidth="0.5"/>
                                    <rightPen lineWidth="0.5"/>
                                </box>
                                <textElement>
                                    <font size="8" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Name]]></text>
                            </staticText>
                            <staticText>
                                <reportElement style="Crosstab Data Text" x="70" y="0" width="70" height="30" uuid="171453ae-fd63-4161-a08f-89df73994cd1"/>
                                <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                    <pen lineWidth="0.5"/>
                                    <topPen lineWidth="0.5"/>
                                    <leftPen lineWidth="0.5"/>
                                    <bottomPen lineWidth="0.5"/>
                                    <rightPen lineWidth="0.5"/>
                                </box>
                                <textElement>
                                    <font size="8" isBold="true"/>
                                </textElement>
                                <text><![CDATA[Surname]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabHeaderCell>
                    <rowGroup name="name" width="70">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{name}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents backcolor="#FFFFFF" mode="Opaque" style="Crosstab Data Text">
                                <textField>
                                    <reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="15" isPrintWhenDetailOverflows="true" uuid="0fd40587-0abc-4bfa-9d7d-97da8996a866"/>
                                    <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                        <pen lineWidth="0.5"/>
                                        <topPen lineWidth="0.5"/>
                                        <leftPen lineWidth="0.5"/>
                                        <bottomPen lineWidth="0.5"/>
                                        <rightPen lineWidth="0.5"/>
                                    </box>
                                    <textElement>
                                        <font size="8"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA[$V{name}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents/>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <rowGroup name="surname" width="70">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{surname}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents backcolor="#FFFFFF" mode="Opaque" style="Crosstab Data Text">
                                <textField>
                                    <reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="15" isPrintWhenDetailOverflows="true" uuid="0fd40587-0abc-4bfa-9d7d-97da8996a866">
                                        <property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
                                    </reportElement>
                                    <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                        <pen lineWidth="0.5"/>
                                        <topPen lineWidth="0.5"/>
                                        <leftPen lineWidth="0.5"/>
                                        <bottomPen lineWidth="0.5"/>
                                        <rightPen lineWidth="0.5"/>
                                    </box>
                                    <textElement>
                                        <font size="8"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA[$V{surname}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents/>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <columnGroup name="level_A" height="30">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{level_A}]]></bucketExpression>
                        </bucket>
                        <crosstabColumnHeader>
                            <cellContents backcolor="#FFFFFF" mode="Opaque" style="Crosstab Data Text">
                                <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                                <textField>
                                    <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="30" uuid="7a721033-ad35-4295-a5ac-4c2dada3f7cf"/>
                                    <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                        <pen lineWidth="0.5"/>
                                        <topPen lineWidth="0.5"/>
                                        <leftPen lineWidth="0.5"/>
                                        <bottomPen lineWidth="0.5"/>
                                        <rightPen lineWidth="0.5"/>
                                    </box>
                                    <textElement>
                                        <font size="8" isBold="true"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA[$V{level_A}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabColumnHeader>
                        <crosstabTotalColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab Data Text"/>
                        </crosstabTotalColumnHeader>
                    </columnGroup>
                    <columnGroup name="level_B" height="20" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{level_B}]]></bucketExpression>
                        </bucket>
                        <crosstabColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab Data Text">
                                <textField>
                                    <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="20" uuid="ef9b89dd-dca1-491e-bb97-c70817f77cc3"/>
                                    <textFieldExpression><![CDATA[$V{level_B}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabColumnHeader>
                        <crosstabTotalColumnHeader>
                            <cellContents>
                                <staticText>
                                    <reportElement x="0" y="0" width="17" height="20" uuid="5f4fc950-1bbd-4c7b-b353-bd6d55eb7c24"/>
                                    <text><![CDATA[Total]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalColumnHeader>
                    </columnGroup>
                    <measure name="level_A_valueMeasure" class="java.math.BigDecimal" calculation="Sum">
                        <measureExpression><![CDATA[$F{level_A_value}]]></measureExpression>
                    </measure>
                    <crosstabCell width="83" height="15">
                        <cellContents>
                            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
                            <textField pattern="#,##0.00;-#,##0.00">
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="15" uuid="0e0f372f-55ea-422f-92c4-806d39a26a0e">
                                    <property name="com.jaspersoft.studio.unit.height" value="px"/>
                                </reportElement>
                                <box topPadding="1" leftPadding="1" bottomPadding="1" rightPadding="1">
                                    <pen lineWidth="0.5"/>
                                    <topPen lineWidth="0.5"/>
                                    <leftPen lineWidth="0.5"/>
                                    <bottomPen lineWidth="0.5"/>
                                    <rightPen lineWidth="0.5"/>
                                </box>
                                <textElement textAlignment="Right">
                                    <font size="8"/>
                                </textElement>
                                <textFieldExpression><![CDATA[$V{level_A_valueMeasure}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="17" height="15" columnTotalGroup="level_B">
                        <cellContents/>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="name" columnTotalGroup="level_B">
                        <cellContents/>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="surname" columnTotalGroup="level_B">
                        <cellContents/>
                    </crosstabCell>
                </crosstab>
            </elementGroup>
        </band>
    </summary>
</jasperReport>```
0 Answers
Related