如何复制交叉表

时间:2016-07-18 11:18:49

标签: jasper-reports

背景:Jaspersoft Studio 6.2

如何正确复制交叉表?例如。我有这个报告,两个交叉表。第二个是通过简单地从第一个复制和粘贴创建的。

enter image description here

但预览时:

enter image description here

第二个显示空值。

来源:

    <?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="6fcf63da-959b-4272-90d7-f36888d89689">
        <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>
        <queryString>
            <![CDATA[select 'a' as item,  'c1' as cat, 10 as value
    union all select 'a' as item,  'c2' as cat, 10 as value
    union all select 'b' as item,  'c1' as cat, 10 as value
    union all select 'b' as item,  'c2' as cat, 10 as value]]>
        </queryString>
        <field name="item" class="java.lang.String"/>
        <field name="cat" class="java.lang.String"/>
        <field name="value" class="java.lang.Integer"/>
        <title>
            <band height="79" splitType="Stretch"/>
        </title>
        <summary>
            <band height="220" splitType="Stretch">
                <crosstab>
                    <reportElement x="0" y="10" width="560" height="90" uuid="c1a01692-6e33-4959-ba10-063d690144f5">
                        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <rowGroup name="item1" width="60" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{item}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="60" height="20" uuid="5cc90958-7226-4ca2-b33d-bc187fd23381"/>
                                    <textFieldExpression><![CDATA[$V{item1}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT">
                                <staticText>
                                    <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="60b92423-2107-47c3-a6c4-eb7644dc9333"/>
                                    <text><![CDATA[Total item1]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <columnGroup name="cat1" height="20" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{cat}]]></bucketExpression>
                        </bucket>
                        <crosstabColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="60" height="20" uuid="6ea9bfbc-51e4-4c0b-9249-04dc3e129caa"/>
                                    <textFieldExpression><![CDATA[$V{cat1}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabColumnHeader>
                        <crosstabTotalColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT">
                                <staticText>
                                    <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="bdb25d96-760e-46a8-9329-d6383f796cc6"/>
                                    <text><![CDATA[Total cat1]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalColumnHeader>
                    </columnGroup>
                    <measure name="value_MEASURE1" class="java.lang.Integer" calculation="Count">
                        <measureExpression><![CDATA[$F{value}]]></measureExpression>
                    </measure>
                    <crosstabCell width="60" height="20">
                        <cellContents mode="Opaque" style="Crosstab_CD">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" uuid="ae67a592-dc64-4cf8-a9ad-565fe05afe91"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" columnTotalGroup="cat1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="ba1cbf16-b568-4e00-b6b6-4b8bae8af5ca"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="item1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="7aa6a6a5-f976-4aad-915b-745598bc6cb5"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="item1" columnTotalGroup="cat1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="1c70e81c-937a-4458-8af7-dc84a4d7337f"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                </crosstab>
                <crosstab>
                    <reportElement x="0" y="130" width="560" height="90" uuid="bc6bf01c-59d7-45d5-95e1-4e2ed10eb4d4">
                        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                        <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                    </reportElement>
                    <rowGroup name="item1" width="60" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{item}]]></bucketExpression>
                        </bucket>
                        <crosstabRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="60" height="20" uuid="2eaed006-01ff-42e6-8094-064f4d64d95f"/>
                                    <textFieldExpression><![CDATA[$V{item1}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabRowHeader>
                        <crosstabTotalRowHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT">
                                <staticText>
                                    <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="e6fa60f1-e100-4da9-ae3c-9857a7c7e4f4"/>
                                    <text><![CDATA[Total item1]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalRowHeader>
                    </rowGroup>
                    <columnGroup name="cat1" height="20" totalPosition="End">
                        <bucket class="java.lang.String">
                            <bucketExpression><![CDATA[$F{cat}]]></bucketExpression>
                        </bucket>
                        <crosstabColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CH">
                                <textField>
                                    <reportElement x="0" y="0" width="60" height="20" uuid="3159af5f-9ee9-42c0-afba-eb5d3a6146d9"/>
                                    <textFieldExpression><![CDATA[$V{cat1}]]></textFieldExpression>
                                </textField>
                            </cellContents>
                        </crosstabColumnHeader>
                        <crosstabTotalColumnHeader>
                            <cellContents mode="Opaque" style="Crosstab_CT">
                                <staticText>
                                    <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="0fe74d0c-15ea-4641-aeb2-f8fb4e4e3474"/>
                                    <text><![CDATA[Total cat1]]></text>
                                </staticText>
                            </cellContents>
                        </crosstabTotalColumnHeader>
                    </columnGroup>
                    <measure name="value_MEASURE1" class="java.lang.Integer" calculation="Count">
                        <measureExpression><![CDATA[$F{value}]]></measureExpression>
                    </measure>
                    <crosstabCell width="60" height="20">
                        <cellContents mode="Opaque" style="Crosstab_CD">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" uuid="5a6a9ee0-2702-4de7-91b4-f1688f8fed40"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" columnTotalGroup="cat1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="6b40b142-41bd-467f-9ce7-01d02d534cd9"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="item1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="5f1889f1-b25f-4d12-8fc9-6fe10245ff2a"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                    <crosstabCell width="60" height="20" rowTotalGroup="item1" columnTotalGroup="cat1">
                        <cellContents mode="Opaque" style="Crosstab_CT">
                            <textField>
                                <reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="02c95509-6115-4147-824e-d0e58445eec2"/>
                                <textFieldExpression><![CDATA[$V{value_MEASURE1}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabCell>
                </crosstab>
            </band>
        </summary>
    </jasperReport>

如何正确复制交叉表?

0 个答案:

没有答案