Jump to content
We've recently updated our Privacy Statement, available here ×

Crosstabs: widths of column headers


andrey_nado

Recommended Posts

Hi!

I'm using crosstab with two column groups - "kind" and "columnId", which use two data columns respectively. Data cells are narrow - 24 points. Width of the second level header cells ("columnId") is the same - obviously. Width of the first level header cells ("kind") depends on how many cells it contains - great!

Now I have to put long test into first level headers (there is a lot of space within them). I'm trying to place text element with width=96 points. This makes my JRXML invalid!

Is it possible to get what I need?

Thanks.

Code:
<?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="myreport" pageWidth="522" pageHeight="300" columnWidth="522" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">	<property name="ireport.scriptlethandling" value="0"/>	<property name="ireport.encoding" value="UTF-8"/>	<import value="net.sf.jasperreports.engine.*"/>	<import value="java.util.*"/>	<import value="net.sf.jasperreports.engine.data.*"/>	<template><![CDATA[msg("{0}styles.jrtx", $P{template_path})]]></template>	<parameter name="template_path" class="java.lang.String" isForPrompting="false"/>	<field name="name" class="java.lang.String"/>	<field name="columnName" class="java.lang.String"/>	<field name="value" class="java.math.BigDecimal"/>	<field name="columnId" class="java.lang.Object"/>	<field name="kind" class="java.lang.Integer"/>	<background>		<band/>	</background>	<title>		<band/>	</title>	<pageHeader>		<band/>	</pageHeader>	<columnHeader>		<band/>	</columnHeader>	<detail>		<band/>	</detail>	<columnFooter>		<band height="78">			<crosstab>				<reportElement x="210" y="0" width="312" height="78"/>				<rowGroup name="name" width="0">					<bucket>						<bucketExpression class="java.lang.String"><![CDATA[null]]></bucketExpression>					</bucket>					<crosstabRowHeader>						<cellContents backcolor="#FFFFFF" mode="Opaque">							<box>								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>							</box>						</cellContents>					</crosstabRowHeader>					<crosstabTotalRowHeader>						<cellContents/>					</crosstabTotalRowHeader>				</rowGroup>				<columnGroup name="colKind" height="30">					<bucket>						<bucketExpression class="java.lang.Integer"><![CDATA[$F{kind}]]></bucketExpression>					</bucket>					<crosstabColumnHeader>						<cellContents backcolor="#FFFFFF" mode="Opaque">							<box>								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>							</box>							<textField>								<reportElement style="normal" x="0" y="0" width="96" height="30"/>								<textElement/>								<textFieldExpression class="java.lang.String"><![CDATA[                                    $V{colKind}.intValue() == 0                                    ? "Very Long Text 1"                                    : $V{colKind}.intValue() == 1                                    ? "Very Long Text 2"                                    : "Very Long Text 3"                                ]]></textFieldExpression>							</textField>						</cellContents>					</crosstabColumnHeader>					<crosstabTotalColumnHeader>						<cellContents/>					</crosstabTotalColumnHeader>				</columnGroup>				<columnGroup name="colName" height="30">					<bucket>						<bucketExpression class="java.lang.Integer"><![CDATA[$F{columnId}]]></bucketExpression>					</bucket>					<crosstabColumnHeader>						<cellContents backcolor="#FFFFFF" mode="Opaque">							<box>								<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>							</box>							<textField>								<reportElement style="normal" x="0" y="0" width="24" height="30"/>								<textElement/>								<textFieldExpression class="java.lang.Integer"><![CDATA[$V{colName}]]></textFieldExpression>							</textField>						</cellContents>					</crosstabColumnHeader>					<crosstabTotalColumnHeader>						<cellContents/>					</crosstabTotalColumnHeader>				</columnGroup>				<measure name="valueMeasure" class="java.math.BigDecimal">					<measureExpression><![CDATA[$F{value}]]></measureExpression>				</measure>				<crosstabCell width="24" height="10">					<cellContents>						<box>							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>						</box>						<textField pattern="#0.00" isBlankWhenNull="true">							<reportElement style="normal" x="0" y="0" width="24" height="10"/>							<textElement textAlignment="Right"/>							<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{valueMeasure}]]></textFieldExpression>						</textField>					</cellContents>				</crosstabCell>				<crosstabCell height="10" rowTotalGroup="name">					<cellContents backcolor="#FFFFFF" mode="Opaque">						<box>							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>						</box>						<textField>							<reportElement style="Crosstab Data Text" x="0" y="0" width="24" height="10"/>							<textElement/>							<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{valueMeasure}]]></textFieldExpression>						</textField>					</cellContents>				</crosstabCell>				<crosstabCell width="24" columnTotalGroup="colName">					<cellContents backcolor="#FFFFFF" mode="Opaque">						<box>							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>						</box>						<textField>							<reportElement style="Crosstab Data Text" x="0" y="0" width="24" height="10"/>							<textElement/>							<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{valueMeasure}]]></textFieldExpression>						</textField>					</cellContents>				</crosstabCell>				<crosstabCell rowTotalGroup="name" columnTotalGroup="colName">					<cellContents backcolor="#FFFFFF" mode="Opaque">						<box>							<pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/>						</box>						<textField>							<reportElement style="Crosstab Data Text" x="0" y="0" width="24" height="10"/>							<textElement/>							<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{valueMeasure}]]></textFieldExpression>						</textField>					</cellContents>				</crosstabCell>			</crosstab>		</band>	</columnFooter>	<pageFooter>		<band/>	</pageFooter>	<summary>		<band/>	</summary></jasperReport>
Link to comment
Share on other sites

  • 4 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 months later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...