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. Please help me. Any reporting tool which can be use with java is helpful. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.