交叉表报告 - 如何创建此类报告 jasper 或 crystal 报告
我想使用交叉表或手动创建交叉表来创建这种类型的报告。我附上了我想要创建的报告视图的图片。
报告视图 - 这是我要创建的报告
<?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 一起使用的报告工具都是有帮助的。谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为要显示的每个字段创建一个度量,并且在计算属性中重要:-选择为第一个
然后您可以使用每个动态生成的字段的这些度量。
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.