Cross Tab Report - Как создать отчет такого типа как отчет о яшме или кристалле - PullRequest
0 голосов
/ 21 февраля 2011

Я хочу создать этот тип отчета с использованием кросс-таблицы или создания кросс-таблицы вручную. Я приложил изображение своего отчета, которое я хочу создать.

Просмотр отчета - это отчет, который я хочу создать

    <?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>

Это ежедневный сводный отчет о продажах. Проблема в том, что когда я создаю отчет с кросс-таблицей, я не могу добавить не группирующие поля, такие как совокупная сумма, цель, баланс. Если я добавлю одно из этих полей, оно автоматически группирует данные. Я не хочу группировать с этими полями. Я просто хочу показать данные в соответствии с их идентификатором. Пожалуйста, помогите мне. Любой инструмент отчетности, который можно использовать с Java, полезен. Спасибо.

1 Ответ

1 голос
/ 20 июня 2012

Вы можете создать Меру для каждого поля, которое вы хотите отобразить, и Важно в свойстве Вычисление: -выберите в качестве Первого

Затем вы можете использовать эти меры для каждого динамически генерируемого поля.

...