Skip to content

Instantly share code, notes, and snippets.

@netslow
Created February 27, 2023 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netslow/2d99656c9076610ed3b749755a54d6d3 to your computer and use it in GitHub Desktop.
Save netslow/2d99656c9076610ed3b749755a54d6d3 to your computer and use it in GitHub Desktop.
Forks and spoons with crosstab
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.20.0-2bc7ab61c56f459e8176eb05c7705e145cd400ad -->
<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="forks-and-spoons" pageWidth="1191" pageHeight="842" orientation="Landscape" columnWidth="1151" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e56c1564-4137-482a-bd33-dbdae76075ae">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="localTst"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<style name="Crosstab_CH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CG" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CT" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Crosstab_CD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="subDataset" uuid="027fc84b-6a65-4218-9bce-08bb389def44">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="localTst"/>
<queryString language="SQL">
<![CDATA[select i.item_id,i.name, s.country, s.day, s.amount
from items i
join items_sales s on i.item_id = s.item_id]]>
</queryString>
<field name="item_id" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="item_id"/>
<property name="com.jaspersoft.studio.field.label" value="item_id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items"/>
</field>
<field name="name" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="name"/>
<property name="com.jaspersoft.studio.field.label" value="name"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items"/>
</field>
<field name="country" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="country"/>
<property name="com.jaspersoft.studio.field.label" value="country"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
<field name="day" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="day"/>
<property name="com.jaspersoft.studio.field.label" value="day"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
<field name="amount" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="amount"/>
<property name="com.jaspersoft.studio.field.label" value="amount"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
</subDataset>
<queryString language="SQL">
<![CDATA[select i.item_id,i.name, s.country, s.day, s.amount
from items i
join items_sales s on i.item_id = s.item_id]]>
</queryString>
<field name="item_id" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="item_id"/>
<property name="com.jaspersoft.studio.field.label" value="item_id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items"/>
</field>
<field name="name" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="name"/>
<property name="com.jaspersoft.studio.field.label" value="name"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items"/>
</field>
<field name="country" class="java.lang.String">
<property name="com.jaspersoft.studio.field.name" value="country"/>
<property name="com.jaspersoft.studio.field.label" value="country"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
<field name="day" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="day"/>
<property name="com.jaspersoft.studio.field.label" value="day"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
<field name="amount" class="java.lang.Integer">
<property name="com.jaspersoft.studio.field.name" value="amount"/>
<property name="com.jaspersoft.studio.field.label" value="amount"/>
<property name="com.jaspersoft.studio.field.tree.path" value="items_sales"/>
</field>
<sortField name="country"/>
<group name="country">
<groupExpression><![CDATA[$F{country}]]></groupExpression>
<groupHeader>
<band height="65" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<textField textAdjust="StretchHeight" isBlankWhenNull="true">
<reportElement mode="Opaque" x="0" y="0" width="1151" height="25" backcolor="#FAEEED" uuid="c175dddf-e626-46c6-a19e-2356627bf1dc">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{country}]]></textFieldExpression>
</textField>
<crosstab>
<reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="25" width="1151" height="40" uuid="e85787f2-03ab-40c1-a28c-ec211e1c248f">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<property name="com.jaspersoft.studio.crosstab.style.header" value="Crosstab_CH"/>
<property name="com.jaspersoft.studio.crosstab.style.group" value="Crosstab_CG"/>
<property name="com.jaspersoft.studio.crosstab.style.total" value="Crosstab_CT"/>
<property name="com.jaspersoft.studio.crosstab.style.detail" value="Crosstab_CD"/>
</reportElement>
<crosstabDataset>
<dataset resetType="Report">
<datasetRun subDataset="subDataset" uuid="44c290d3-1003-43ce-9f9b-a1dd512e70a5">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
</dataset>
</crosstabDataset>
<crosstabHeaderCell>
<cellContents>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<staticText>
<reportElement x="0" y="0" width="60" height="20" uuid="eb2a2f5e-c944-4950-ab7c-22562349fc8f"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Id]]></text>
</staticText>
<staticText>
<reportElement x="60" y="0" width="60" height="20" uuid="866cab22-42fb-44dc-910f-25737f77b5b8"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Name]]></text>
</staticText>
</cellContents>
</crosstabHeaderCell>
<rowGroup name="item_id" width="60">
<bucket class="java.lang.Integer">
<bucketExpression><![CDATA[$F{item_id}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="e599cdec-d797-4291-8c04-2d04d8e2b169"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{item_id}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="120" height="20" uuid="bfc19290-7921-4c12-b83b-07f4885c2760"/>
<text><![CDATA[Total item_id]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<rowGroup name="name" width="60">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{name}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="8e9503a0-36f5-4f2c-bf1c-5f0febf18de4"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{name}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents mode="Opaque" style="Crosstab_CG">
<staticText>
<reportElement x="0" y="0" width="60" height="20" uuid="887fed1a-fd21-4ddd-a94d-dd9b91457e49"/>
<text><![CDATA[Total name]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="day" height="20" totalPosition="Start">
<bucket class="java.lang.Integer">
<bucketExpression><![CDATA[$F{day}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="8c26a835-020d-4384-966d-1774bb4d2b28"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{day}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="20" uuid="0d9f9063-0033-47c2-b43e-b7ad3e3ace10"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Total]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="amount_MEASURE" class="java.lang.Integer" calculation="First">
<measureExpression><![CDATA[$F{amount}]]></measureExpression>
</measure>
<crosstabCell width="60" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="60" height="20" uuid="caadf17b-6d92-4198-be52-76f4a6a2c224"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="day">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="60" height="20" uuid="6720356e-ab18-4166-b982-a13aca179150"/>
<box>
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="item_id">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="bf18a1cc-77a5-4235-9020-975f821ba902"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="item_id" columnTotalGroup="day">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="fdcd4b76-1077-423a-97ea-d9867f06c061"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="name">
<cellContents mode="Opaque" style="Crosstab_CG">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="047e6e2d-f599-48c9-8fc6-44b263ebdf5f"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="name" columnTotalGroup="day">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="8acb77f7-b071-49da-bb01-c3410f49d802"/>
<textFieldExpression><![CDATA[$V{amount_MEASURE}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</groupHeader>
</group>
</jasperReport>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment