我想使用交叉表创建此类报告或手动创建交叉表。我附上了我要创建的报告视图的图片。
Report View - 这是我要创建的报告
<?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>
这是每日销售摘要报告。问题是,当我使用交叉表创建报表时,我无法添加非分组字段,如累计总计,目标,余额。如果我添加其中一个字段,它会自动分组数据。我不想与这些领域分组。我只想根据其项目ID显示数据。请帮我。任何可以与java一起使用的报告工具都很有帮助。谢谢。
答案 0 :(得分:1)
您可以为要显示的每个字段和计算属性中的重要字段创建度量: - 选择为第一个
然后,您可以对每个动态生成的字段使用这些度量。