andrey_nado Posted January 29, 2010 Share Posted January 29, 2010 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 More sharing options...
lucianc Posted February 23, 2010 Share Posted February 23, 2010 The header of the first group will be stretched at runtime. At design time, you'll have to set a width that corresponds to the minimal width of the header.Regards,Lucian Link to comment Share on other sites More sharing options...
andrey_nado Posted May 12, 2010 Author Share Posted May 12, 2010 I reviewed JR manual and found solution: headerPosition="Stretch".Thank you, Lucian!I would be great if iReport could edit this property too. Link to comment Share on other sites More sharing options...
lucianc Posted May 12, 2010 Share Posted May 12, 2010 andrey_nadoWrote: I would be great if iReport could edit this property too. Please log this using the iReport project's trackers at http://jasperforge.org/projects/ireport/tracker/myviewRegards,Lucian Link to comment Share on other sites More sharing options...
gozalito_128 Posted December 24, 2013 Share Posted December 24, 2013 I set the property headerPosition="Stretch" in the XML tag like this then switched to the Designer tab and next clicked the Preview tab, PRESTO!, got the column header horizontal aligned to the center. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now