Jasper reports 默认情况下交叉表应用计算函数

Jasper reports 默认情况下交叉表应用计算函数,jasper-reports,crosstab,Jasper Reports,Crosstab,我用数据集制作了一个交叉表,如下所示 我希望度量列上没有计算功能。但是,在默认情况下,报表运行时总是取最高值,结果如下所示。如何让报表只提供数据透视而不对度量值执行任何计算 我希望数据如下图所示 请在下面找到相关的jrxml <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="h

我用数据集制作了一个交叉表,如下所示

我希望度量列上没有计算功能。但是,在默认情况下,报表运行时总是取最高值,结果如下所示。如何让报表只提供数据透视而不对度量值执行任何计算

我希望数据如下图所示

请在下面找到相关的jrxml

 <?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="crosstabmeasure" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e47b3f7d-1e00-4702-a900-be50a229f085">
    <import value="org.apache.commons.lang3.time.*"/>
    <import value="java.util.Date"/>
    <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_CG" mode="Opaque" backcolor="#BFE1FF">
        <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>
    <subDataset name="set1" uuid="0271cb46-f184-47b2-8ab3-e6ee96ea33ef">
        <parameter name="Locale" class="java.lang.String"/>
        <parameter name="UtcOffSet" class="java.lang.Integer"/>
        <queryString>
            <![CDATA[select @curRank := @curRank + 1 AS rank, inter.*
from internatioinlization inter, (SELECT @curRank := 0) r
where 1 = case when  1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1  else 0 end]]>
        </queryString>
        <field name="rank" class="java.lang.Double"/>
        <field name="col1" class="java.lang.String"/>
        <field name="col2" class="java.lang.Integer"/>
        <field name="col3" class="java.sql.Timestamp"/>
        <field name="col4" class="java.lang.String"/>
    </subDataset>
    <parameter name="Locale" class="java.lang.String"/>
    <parameter name="UtcOffSet" class="java.lang.Integer"/>
    <queryString>
        <![CDATA[select @curRank := @curRank + 1 AS rank, inter.*
from internatioinlization inter, (SELECT @curRank := 0) r
where 1 = case when  1 = 1 and $P{Locale} is not null and $P{UtcOffSet} is not null then 1  else 0 end]]>
    </queryString>
    <field name="rank" class="java.lang.Double"/>
    <field name="col1" class="java.lang.String"/>
    <field name="col2" class="java.lang.Integer"/>
    <field name="col3" class="java.sql.Timestamp"/>
    <field name="col4" class="java.lang.String"/>
    <summary>
        <band height="211" splitType="Stretch">
            <crosstab>
                <reportElement x="0" y="0" width="555" height="211" uuid="6c5ccb8a-50fc-4158-b2ba-88d864aa1e43">
                </reportElement>
                <crosstabParameter name="Locale">
                    <parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("Locale")]]></parameterValueExpression>
                </crosstabParameter>
                <crosstabParameter name="UtcOffSet" class="java.lang.Integer">
                    <parameterValueExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}.get("UtcOffSet")]]></parameterValueExpression>
                </crosstabParameter>
                <crosstabDataset>
                    <dataset>
                        <datasetRun subDataset="set1" uuid="d255c9b9-fbb2-420a-8ef5-3236098654f1">
                            <datasetParameter name="Locale">
                                <datasetParameterExpression><![CDATA[$P{Locale}]]></datasetParameterExpression>
                            </datasetParameter>
                            <datasetParameter name="UtcOffSet">
                                <datasetParameterExpression><![CDATA[$P{UtcOffSet}]]></datasetParameterExpression>
                            </datasetParameter>
                            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                        </datasetRun>
                    </dataset>
                </crosstabDataset>
                <rowGroup name="col11" width="60">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{col1}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" uuid="86c09a7f-46b5-4d2f-ba87-715f99d832a8"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$V{col11}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents>
                            <staticText>
                                <reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="94fca0ea-1572-4d42-85d9-b06f92c73b6e"/>
                                <text><![CDATA[Total col11]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <columnGroup name="col41" height="20">
                    <bucket class="java.lang.String">
                        <bucketExpression><![CDATA[$F{col4}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents mode="Opaque" style="Crosstab_CH">
                            <textField>
                                <reportElement x="0" y="0" width="120" height="20" uuid="137ef406-6a2e-4629-9d38-4858c4a5ae2c"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <textFieldExpression><![CDATA[$V{col41}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents>
                            <staticText>
                                <reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="5c71211d-f1db-4911-8923-2bdb208ddb99"/>
                                <text><![CDATA[Total col41]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <measure name="col2_MEASURE1" class="java.lang.Integer">
                    <measureExpression><![CDATA[$F{col2}]]></measureExpression>
                </measure>
                <measure name="col3_MEASURE1" class="java.sql.Timestamp">
                    <measureExpression><![CDATA[$F{col3}]]></measureExpression>
                </measure>
                <crosstabCell width="120" height="20">
                    <cellContents mode="Opaque" style="Crosstab_CD">
                        <textField>
                            <reportElement x="0" y="0" width="60" height="20" uuid="861d0d3a-d774-4b0c-ae7d-ace315bf305c"/>
                            <box>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="60" y="0" width="60" height="20" uuid="163ed502-e753-444a-942d-832d84da0a5f"/>
                            <box>
                                <topPen lineWidth="0.5"/>
                                <leftPen lineWidth="0.5"/>
                                <bottomPen lineWidth="0.5"/>
                                <rightPen lineWidth="0.5"/>
                            </box>
                            <textElement textAlignment="Center" verticalAlignment="Middle"/>
                            <textFieldExpression><![CDATA[$V{col3_MEASURE1} != null ? DateFormat.getDateInstance(DateFormat.SHORT, new Locale($P{Locale}.split("-")[0], $P{Locale}.split("-")[1])).format(DateUtils.addMinutes($V{col3_MEASURE1},$P{UtcOffSet})) : null]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="60" height="20" columnTotalGroup="col41">
                    <cellContents mode="Opaque" style="Crosstab_CT">
                        <textField>
                            <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="2576b9e2-3bba-40e3-aa15-5f4f0aada549"/>
                            <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="a111181f-b60f-4afd-8292-9e260c1b9ce2"/>
                            <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="60" height="20" rowTotalGroup="col11">
                    <cellContents mode="Opaque" style="Crosstab_CT">
                        <textField>
                            <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="9adf6c9c-acee-4673-8b70-a376e7d1cbb4"/>
                            <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="9baedeed-4770-4153-b639-afc0965e9467"/>
                            <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="60" height="20" rowTotalGroup="col11" columnTotalGroup="col41">
                    <cellContents mode="Opaque" style="Crosstab_CT">
                        <textField>
                            <reportElement x="0" y="0" width="60" height="10" forecolor="#FFFFFF" uuid="a2805e0a-080d-42be-ad86-a7e8e666f571"/>
                            <textFieldExpression><![CDATA[$V{col2_MEASURE1}]]></textFieldExpression>
                        </textField>
                        <textField>
                            <reportElement x="0" y="10" width="60" height="10" forecolor="#FFFFFF" uuid="c485f69d-91e1-4b19-a8ab-bdbfa3cafcc6"/>
                            <textFieldExpression><![CDATA[$V{col3_MEASURE1}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
            </crosstab>
        </band>
    </summary>
</jasperReport>

如果要防止col1行组的bucketing/aggregation,可以添加第二个行组(没有标题单元格),该行组的每个记录都有不同的值。例如:

        <rowGroup name="RecNo" width="0">
            <bucket class="java.lang.Integer">
                <bucketExpression>$V{REPORT_COUNT}</bucketExpression>
            </bucket>
        </rowGroup>

$V{报告计数}

您等待的结果是什么数据(最好发布图像)?对于粘贴错误的jrxml表示歉意。我已经在主要问题中更新了新的jrxml。请看一下新代码。此外,我还附上了一张包含数据外观要求的图片
我希望度量列上没有计算功能
-在交叉表中显示组的一些聚合结果是常见的行为。您对交叉表的工作方式有一些误解。您可以使用col2和col3添加列,并使用隐藏标题和显示此值。在某些情况下,子报表/列表组件的放置与Alex相比是一个很好的差异,即使添加了“无计算函数”,聚合仍然会发生。我理解交叉表通常用于显示聚合。因为有一个不计算任何聚合的选项,所以我想了解为什么这个选项不起作用