简体   繁体   English

交叉表报告-如何创建这种类型的报告碧玉或水晶报告

[英]Cross Tab Report - How to create this type of report jasper or crystal report

I want to create this type of a report using cross tab or creating cross tab manually. 我想使用交叉表或手动创建交叉表来创建这种类型的报告。 I attached picture of my report view which I want to create. 我附上了要创建的报告视图的图片。

Report View - this is the report which I want to create 报告视图 -这是我要创建的报告

    <?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="DailySalesSummary" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <style name="Crosstab Data Text" hAlign="Center">
        <box>
            <pen lineWidth="0.0"/>
            <topPen lineWidth="0.0"/>
            <leftPen lineWidth="0.0"/>
            <bottomPen lineWidth="0.0"/>
            <rightPen lineWidth="0.0"/>
        </box>
    </style>
    <queryString>
        <![CDATA[SELECT inv.invoiceId,itm.name as itmN,isi.qty,bnd.name as bname FROM invoice_stock_item isi
join invoice inv on inv.invoiceId = isi.invoiceId
join item itm on itm.itemId = isi.itemId
join brand_item bni on bni.itemId=itm.itemId
join brand bnd on bnd.brandId=bni.brandId
where inv.status ='1']]>
    </queryString>
    <field name="invoiceId" class="java.lang.Integer"/>
    <field name="itmN" class="java.lang.String"/>
    <field name="qty" class="java.lang.Integer"/>
    <field name="bname" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="572" splitType="Stretch">
            <crosstab>
                <reportElement x="0" y="0" width="752" height="572"/>
                <rowGroup name="bname" width="70" totalPosition="End">
                    <bucket>
                        <bucketExpression class="java.lang.String"><![CDATA[$F{bname}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="13"/>
                                <textElement/>
                                <textFieldExpression class="java.lang.String"><![CDATA[$V{bname}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents backcolor="#005FB3" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="140" height="16" forecolor="#FFFFFF"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Total bname]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <rowGroup name="itmN" width="70" totalPosition="End">
                    <bucket>
                        <bucketExpression class="java.lang.String"><![CDATA[$F{itmN}]]></bucketExpression>
                    </bucket>
                    <crosstabRowHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="70" height="13"/>
                                <textElement textAlignment="Left" verticalAlignment="Middle">
                                    <font size="8"/>
                                </textElement>
                                <textFieldExpression class="java.lang.String"><![CDATA[$V{itmN}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabRowHeader>
                    <crosstabTotalRowHeader>
                        <cellContents backcolor="#BFE1FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                        </cellContents>
                    </crosstabTotalRowHeader>
                </rowGroup>
                <columnGroup name="invoiceId" height="30" totalPosition="End">
                    <bucket>
                        <bucketExpression class="java.lang.Integer"><![CDATA[$F{invoiceId}]]></bucketExpression>
                    </bucket>
                    <crosstabColumnHeader>
                        <cellContents backcolor="#F0F8FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textField>
                                <reportElement style="Crosstab Data Text" x="0" y="0" width="16" height="30"/>
                                <textElement textAlignment="Left" rotation="Left"/>
                                <textFieldExpression class="java.lang.Integer"><![CDATA[$V{invoiceId}]]></textFieldExpression>
                            </textField>
                        </cellContents>
                    </crosstabColumnHeader>
                    <crosstabTotalColumnHeader>
                        <cellContents backcolor="#BFE1FF" mode="Opaque">
                            <box>
                                <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <staticText>
                                <reportElement x="0" y="0" width="50" height="30"/>
                                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                <text><![CDATA[Total invoiceId]]></text>
                            </staticText>
                        </cellContents>
                    </crosstabTotalColumnHeader>
                </columnGroup>
                <measure name="qtyMeasure" class="java.lang.Integer" calculation="Sum">
                    <measureExpression><![CDATA[$F{qty}]]></measureExpression>
                </measure>
                <crosstabCell width="16" height="13">
                    <cellContents>
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="16" height="13"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.Integer"><![CDATA[$V{qtyMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="16" height="16" rowTotalGroup="bname">
                    <cellContents backcolor="#005FB3" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="16" height="16" forecolor="#FFFFFF"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.Integer"><![CDATA[$V{qtyMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="50" height="13" columnTotalGroup="invoiceId">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="13"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.Integer"><![CDATA[$V{qtyMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="16" rowTotalGroup="bname" columnTotalGroup="invoiceId">
                    <cellContents backcolor="#005FB3" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textField>
                            <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="16" forecolor="#FFFFFF"/>
                            <textElement/>
                            <textFieldExpression class="java.lang.Integer"><![CDATA[$V{qtyMeasure}]]></textFieldExpression>
                        </textField>
                    </cellContents>
                </crosstabCell>
                <crosstabCell width="16" height="0" rowTotalGroup="itmN">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                    </cellContents>
                </crosstabCell>
                <crosstabCell height="0" rowTotalGroup="itmN" columnTotalGroup="invoiceId">
                    <cellContents backcolor="#BFE1FF" mode="Opaque">
                        <box>
                            <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                    </cellContents>
                </crosstabCell>
            </crosstab>
        </band>
    </summary>
</jasperReport>

This is daily sales summary report. 这是每日销售摘要报告。 The problem is when I create the report with cross tab I couldn't add non grouping fields like cumulative total, target, balance. 问题是,当我使用交叉表创建报表时,无法添加非分组字段,例如累计总计,目标,余额。 If I add one of these fields it automatically grouping data. 如果添加这些字段之一,它将自动将数据分组。 I don't want to group with these fields. 我不想与这些领域分组。 I just want to show data according to its item id. 我只想根据其项目ID显示数据。 Please help me. 请帮我。 Any reporting tool which can be use with java is helpful. 可以与Java一起使用的任何报告工具都是有帮助的。 Thank you. 谢谢。

You can create a Measure for each field that you want to show and Important in Calculation property:-select as First 您可以为每个要显示的字段创建一个度量,并在“计算中重要”属性中:-选择“第一”

Then you can use these measure of each dynamically generated fields. 然后,您可以对每个动态生成的字段使用这些度量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM