Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

JasperReports - mehrere SQL-Statements für Crosstab

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe eine spezielle Frage an JasperReports-Kenner.

Ich versuche, den jrxml-Bericht mit einer Crosstab zu erstellen. Dabei ist es möglich, einen subDataset zu definieren und eine zusätzliche SQL-Query einzubinden.

Ist es denn überhaupt möglich, innerhalb einer Crostab mehrere subDatasets zu definieren?

Hier ist die jrxml-Datei:



<?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="Grabdaten_Erfassung" pageWidth="595" pageHeight="842" columnWidth="565" leftMargin="15" rightMargin="15" topMargin="10" bottomMargin="10">

	<style name="Arial_Normal" isDefault="true" fontName="Arial" fontSize="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

	<style name="Arial_Bold" isDefault="false" fontName="Arial" fontSize="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

	<subDataset name="FBEZIRK_DATEN">

		<parameter name="BEZIRK" class="java.lang.String"/>

		<queryString>

			<![CDATA[SELECT FRIEDHOF, COUNT(ol_ghaupt.KINDEX) as ANZAHL, ol_friedhof.FNR FROM  ol_friedhof LEFT JOIN ol_ghaupt ON ol_friedhof.FNR = ol_ghaupt.FNR AND ol_friedhof.MANDANT_ID = ol_ghaupt.MANDANT_ID WHERE ol_friedhof.MANDANT_ID = 100010 AND ol_friedhof.FBEZIRK = $P{BEZIRK} GROUP BY FRIEDHOF, ol_friedhof.FNR]]>

		</queryString>

		<field name="FRIEDHOF" class="java.lang.String"/>

		<field name="ANZAHL" class="java.lang.Integer"/>

		<field name="FNR" class="java.lang.String"/>

	</subDataset>

	<queryString>

		<![CDATA[SELECT DISTINCT FBEZIRK FROM ol_friedhof WHERE MANDANT_ID = 100010]]>

	</queryString>

	<field name="FBEZIRK" class="java.lang.String"/>

	<title>

		<band height="50">

			<staticText>

				<reportElement x="0" y="0" width="140" height="20"/>

				<textElement>

					<font fontName="Arial" size="14" isBold="true"/>

				</textElement>

				<text><![CDATA[Grabdatenerfassung]]></text>

			</staticText>

			<textField pattern="dd.MM.yyyy">

				<reportElement x="465" y="0" width="100" height="20"/>

				<textElement textAlignment="Right">

					<font fontName="Arial" size="14" isBold="true"/>

				</textElement>

				<textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>

			</textField>

		</band>

	</title>

	<detail>

		<band height="70" splitType="Stretch">

			<crosstab isRepeatColumnHeaders="false">

				<reportElement mode="Opaque" x="0" y="0" width="565" height="60"/>

				<crosstabParameter name="BEZIRK">

					<parameterValueExpression><![CDATA[$F{FBEZIRK}]]></parameterValueExpression>

				</crosstabParameter>

				<crosstabDataset>

					<dataset>

						<datasetRun subDataset="FBEZIRK_DATEN">

							<datasetParameter name="BEZIRK">

								<datasetParameterExpression><![CDATA[$F{FBEZIRK}]]></datasetParameterExpression>

							</datasetParameter>

						</datasetRun>					

					</dataset>

				</crosstabDataset>

				<rowGroup name="Friedhof" width="120" totalPosition="End">

					<bucket>

						<bucketExpression class="java.lang.String"><![CDATA[$F{FRIEDHOF}]]></bucketExpression>

					</bucket>

					<crosstabRowHeader>

						<cellContents backcolor="#FFFFFF" mode="Opaque">

							<box>

								<topPen lineWidth="1.0" lineStyle="Solid"/>

								<leftPen lineWidth="1.0" lineStyle="Solid"/>

								<bottomPen lineWidth="1.0" lineStyle="Solid"/>

								<rightPen lineWidth="1.0" lineStyle="Solid"/>

							</box>

							<textField>

								<reportElement x="5" y="5" width="110" height="20"/>

								<textElement>

									<font size="10"/>

								</textElement>

								<textFieldExpression class="java.lang.String"><![CDATA[$V{Friedhof}]]></textFieldExpression>

							</textField>

						</cellContents>

					</crosstabRowHeader>

					<crosstabTotalRowHeader>

						<cellContents backcolor="#999999" mode="Opaque">

							<box>

								<topPen lineWidth="1.0" lineStyle="Solid"/>

								<leftPen lineWidth="1.0" lineStyle="Solid"/>

								<bottomPen lineWidth="1.0" lineStyle="Solid"/>

								<rightPen lineWidth="1.0" lineStyle="Solid"/>

							</box>

							<textField>

								<reportElement x="5" y="5" width="110" height="20"/>

								<textElement>

									<font size="10"/>

								</textElement>

								<textFieldExpression class="java.lang.String"><![CDATA[$P{BEZIRK} + " gesamt:"]]></textFieldExpression>

							</textField>

						</cellContents>

					</crosstabTotalRowHeader>

				</rowGroup>

				<columnGroup name="Grabanzahl" height="30" totalPosition="End" headerPosition="Stretch">

					<bucket>

						<bucketExpression class="java.lang.Integer"><![CDATA[($F{ANZAHL})]]></bucketExpression>

					</bucket>

					<crosstabColumnHeader>

						<cellContents backcolor="#FFFFFF" mode="Opaque">

							<box>

								<topPen lineWidth="1.0" lineStyle="Solid"/>

								<leftPen lineWidth="1.0" lineStyle="Solid"/>

								<bottomPen lineWidth="1.0" lineStyle="Solid"/>

								<rightPen lineWidth="1.0" lineStyle="Solid"/>

							</box>

						</cellContents>

					</crosstabColumnHeader>

					<crosstabTotalColumnHeader>

						<cellContents backcolor="#FFFFFF" mode="Opaque">

							<box>

								<topPen lineWidth="1.0" lineStyle="Solid"/>

								<leftPen lineWidth="1.0" lineStyle="Solid"/>

								<bottomPen lineWidth="1.0" lineStyle="Solid"/>

								<rightPen lineWidth="1.0" lineStyle="Solid"/>

							</box>

							<staticText>

								<reportElement x="10" y="5" width="60" height="20"/>

								<textElement textAlignment="Center">

									<font size="12" isBold="true"/>

								</textElement>

								<text><![CDATA[Gräber]]></text>

							</staticText>

						</cellContents>

					</crosstabTotalColumnHeader>

				</columnGroup>

				<measure name="ANZAHLSum" class="java.lang.Integer" calculation="Sum">

					<measureExpression><![CDATA[$F{ANZAHL}]]></measureExpression>

				</measure>

				<crosstabCell width="0" height="25">

					<cellContents backcolor="#FFFFFF" mode="Transparent">

						<box>

							<topPen lineWidth="1.0" lineStyle="Solid"/>

							<leftPen lineWidth="1.0" lineStyle="Solid"/>

							<bottomPen lineWidth="1.0" lineStyle="Solid"/>

							<rightPen lineWidth="1.0" lineStyle="Solid"/>

						</box>

					</cellContents>

				</crosstabCell>

				<crosstabCell width="80" height="25" columnTotalGroup="Grabanzahl">

					<cellContents backcolor="#FFFFFF" mode="Opaque">

						<box>

							<topPen lineWidth="1.0" lineStyle="Solid"/>

							<leftPen lineWidth="1.0" lineStyle="Solid"/>

							<bottomPen lineWidth="1.0" lineStyle="Solid"/>

							<rightPen lineWidth="1.0" lineStyle="Solid"/>

						</box>

						<textField pattern="##.###">

							<reportElement style="Arial_Bold" x="10" y="0" width="60" height="25"/>

							<textElement textAlignment="Right" verticalAlignment="Middle">

								<font size="10"/>

							</textElement>

							<textFieldExpression class="java.lang.Integer"><![CDATA[$V{ANZAHLSum}]]></textFieldExpression>

						</textField>

					</cellContents>

				</crosstabCell>

				<crosstabCell width="80" height="25" rowTotalGroup="Friedhof" columnTotalGroup="Grabanzahl">

					<cellContents backcolor="#999999" mode="Opaque">

						<box>

							<topPen lineWidth="1.0" lineStyle="Solid"/>

							<leftPen lineWidth="1.0" lineStyle="Solid"/>

							<bottomPen lineWidth="1.0" lineStyle="Solid"/>

							<rightPen lineWidth="1.0" lineStyle="Solid"/>

						</box>

						<textField pattern="##.###">

							<reportElement style="Arial_Bold" x="10" y="0" width="60" height="25"/>

							<textElement textAlignment="Right" verticalAlignment="Middle">

								<font size="10"/>

							</textElement>

							<textFieldExpression class="java.lang.Integer"><![CDATA[$V{ANZAHLSum}]]></textFieldExpression>

						</textField>

					</cellContents>

				</crosstabCell>

			</crosstab>

		</band>

	</detail>

</jasperReport>


Danke für die Antworten!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.