3

enter image description here

This picture shows a sample of what my columns look like in my crosstab (I have two column groups - in this case a date and status). The date should be centered across the 5 columns and I have set the horizontal to be centered. However, it's only centering it based on the size I have set in iReport. I've tried adjusting the various settings but have been unable to center that first row. I'm using JasperReports 4.0.1.

Alex K
  • 22,315
  • 19
  • 108
  • 236
nevets1219
  • 7,692
  • 4
  • 32
  • 47

1 Answers1

4

I know it's a little late, but this is how yo do it:

when you declare the columnGroup element, set the headerPosition attribute to "Stretch". Example:

<columnGroup name="month" height="20" headerPosition="Stretch">
    <bucket>
        <bucketExpression class="java.lang.String"><![CDATA[$F{month}]]></bucketExpression>
    </bucket>
    <crosstabColumnHeader>
        <cellContents backcolor="#999999" 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="20"/>
                <textElement verticalAlignment="Middle"/>
                <textFieldExpression class="java.lang.String"><![CDATA[$V{month}]]></textFieldExpression>
            </textField>
        </cellContents>
    </crosstabColumnHeader>
    <crosstabTotalColumnHeader>
        <cellContents/>
    </crosstabTotalColumnHeader>

Regards, Damian

damian
  • 4,024
  • 5
  • 35
  • 53