i.e
<columnGroup name="column11" height="20" totalPosition="Start" headerPosition="Stretch">

demo

result :  header part : col1111

data source:

jasper file :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 5.5.1 -->
<!-- 2016-11-04T14:16:41 -->
<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="nanancrosstab" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="83ac89eb-10c4-4c29-8dd3-59ffa793d713">
<style name="Crosstab_CH" mode="Opaque" backcolor="#F0F8FF">
<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="#BFE1FF">
<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="#005FB3">
<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>
<queryString language="CSV">
<![CDATA[]]>
</queryString>
<field name="row1" class="java.lang.String"/>
<field name="row2" class="java.lang.String"/>
<field name="column1" class="java.lang.String"/>
<field name="column2" class="java.lang.String"/>
<field name="total" class="java.lang.String"/>
<background>
<band splitType="Stretch"/>
</background>
<summary>
<band height="208" splitType="Stretch">
<crosstab>
<reportElement x="0" y="8" width="550" height="200" uuid="e01ca2a5-bc71-40d8-bc5e-81533045b333">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
</reportElement>
<rowGroup name="row11" width="60">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{row1}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="3ff09f7a-8383-4fba-a01a-5939e42e97e3"/>
<textFieldExpression><![CDATA[$V{row11}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents>
<staticText>
<reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="12b3e0d4-d51a-437e-91ed-d77470b1cfc2"/>
<text><![CDATA[Total row11]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<rowGroup name="row21" width="60">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{row2}]]></bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="5988f665-b81b-4f92-bb2d-bed07e2029dc"/>
<textFieldExpression><![CDATA[$V{row21}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabRowHeader>
<crosstabTotalRowHeader>
<cellContents>
<staticText>
<reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="62fd2a86-8b30-476c-872d-aade860a57d0"/>
<text><![CDATA[Total row21]]></text>
</staticText>
</cellContents>
</crosstabTotalRowHeader>
</rowGroup>
<columnGroup name="column11" height="20" totalPosition="Start" headerPosition="Stretch">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{column1}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="af8fba4b-affa-4d34-9018-783604964e90"/>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{column11}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CT">
<staticText>
<reportElement x="0" y="0" width="60" height="40" forecolor="#FFFFFF" uuid="83b6a124-78e5-46e1-a525-3f10b15f6157"/>
<text><![CDATA[Total column11]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<columnGroup name="column21" height="20">
<bucket class="java.lang.String">
<bucketExpression><![CDATA[$F{column2}]]></bucketExpression>
</bucket>
<crosstabColumnHeader>
<cellContents mode="Opaque" style="Crosstab_CH">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="b71c29cf-9284-4f61-80da-fcc5071a3fd8"/>
<textFieldExpression><![CDATA[$V{column21}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabColumnHeader>
<crosstabTotalColumnHeader>
<cellContents>
<staticText>
<reportElement x="0" y="0" width="-2147483648" height="-2147483648" uuid="2b435028-6b6f-415c-9a4f-9309f76fb057"/>
<text><![CDATA[Total column21]]></text>
</staticText>
</cellContents>
</crosstabTotalColumnHeader>
</columnGroup>
<measure name="total_MEASURE1" class="java.lang.Integer" calculation="Count">
<measureExpression><![CDATA[$F{total}]]></measureExpression>
</measure>
<crosstabCell width="60" height="20">
<cellContents mode="Opaque" style="Crosstab_CD">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="6d820ded-d85d-4ed7-972c-40072f3ae870"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="column11">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="66f89360-84b4-494c-a18e-8506773cda8b"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" columnTotalGroup="column21">
<cellContents mode="Opaque" style="Crosstab_CG">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="769e326c-a7f0-4ee3-96f9-9d5a4d8097a8"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row11">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="5a75ad84-53dd-42e0-accc-59581569fdd5"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row11" columnTotalGroup="column11">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="085aef20-d954-438d-9959-4ec702c855e1"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row11" columnTotalGroup="column21">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="d0e69f40-ea94-407c-b73f-1abec2d221ca"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row21">
<cellContents mode="Opaque" style="Crosstab_CG">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="59273a52-60c7-4398-96bc-b0225ab51b9e"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row21" columnTotalGroup="column11">
<cellContents mode="Opaque" style="Crosstab_CT">
<textField>
<reportElement x="0" y="0" width="60" height="20" forecolor="#FFFFFF" uuid="4b102117-1136-45a9-8f9d-4691bb749772"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
<crosstabCell width="60" height="20" rowTotalGroup="row21" columnTotalGroup="column21">
<cellContents mode="Opaque" style="Crosstab_CG">
<textField>
<reportElement x="0" y="0" width="60" height="20" uuid="e800c1be-431e-48ef-93ce-3ae054ef52d7"/>
<textFieldExpression><![CDATA[$V{total_MEASURE1}]]></textFieldExpression>
</textField>
</cellContents>
</crosstabCell>
</crosstab>
</band>
</summary>
</jasperReport>

jrxml

jasper API:

Position of Totals Row
The totalPosition attribute controls the appearance of the row that displays the totals for the row group:

Start: The row that displays the totals for the group precedes the rows corresponding to the groupfs bucket values (totalPosition="Start").
End: The row that displays the totals for the group is rendered after the rows corresponding to the groupfs bucket values (totalPosition="End").
None: The row that displays the totals for the group is not displayed (totalPosition= "None").

Row Header Stretch Behavior
When multiple nested row groups are used in the crosstab, the height of the row headers for the higher-level groups grows in order to wrap the rows of the nested groups. The headerPosition attribute determines how the row header content should adapt to the increased height. The possible values for this attribute are as follows:

Top: The content of the row header does not stretch and remains at the top of the header area (headerPosition="Top").
Middle: The content of the row header does not stretch and moves to the middle of the header area (headerPosition="Middle").
Bottom: The content of the row header does not stretch and moves to the bottom of the header area (headerPosition="Bottom").
Stretch: The content of the row header adapts its height proportionally to the newly increased row header height (headerPosition="Stretch").
default, the row header content stays at the top of the row header area.

COLUMN GROUPS
As previously mentioned for the row groups, a crosstab can contain any number of
nested columns. The order of column groups is also important.
below gives the JRXML syntax for column groups.

<!ELEMENT columnGroup (bucket, crosstabColumnHeader?,crosstabTotalColumnHeader?)>
<!ATTLIST columnGroup
name CDATA #REQUIRED
height NMTOKEN #REQUIRED
totalPosition (Start | End | None) "None"
headerPosition (Left | Center | Right | Stretch) "Left"
>
<!ELEMENT crosstabColumnHeader (cellContents?)>
<!ELEMENT crosstabTotalColumnHeader (cellContents?)>

最新文章

  1. ionic第二坑——ionic 上拉菜单(ActionSheet)安卓样式坑
  2. mybatis 传递参数的方法总结
  3. poj 1701【数学几何】
  4. 使用paramiko模块远程登录并上传或下载文件
  5. Android自动检测版本及自动升级
  6. List&lt;HashMap&gt;和HashMap
  7. Gym 101102C Bored Judge(set--结构体集合)
  8. js获取页面的来源页
  9. JPA 系列教程8-双向一对一共享主键
  10. React编写input组件传参共用onChange
  11. Uncaught ReferenceError: jQuery is not defined
  12. java中,什么是构造函数?什么是构造函数重载?什么是复制构造函数?
  13. appium如何解决每次都要安装apk的烦恼
  14. 【洛谷P4097】Segment 李超线段树
  15. HTML表单与输入实例
  16. 微信小程序——引用阿里云字体
  17. linux统计文件夹内文件数
  18. python 对mongodb进行压力测试
  19. [SDOI2009]HH的项链 树状数组 BZOJ 1878
  20. linux的screen常用命令使用记录

热门文章

  1. 数据结构之 图论---最小生成树(prim + kruskal)
  2. BestCoder7 1001 Little Pony and Permutation(hdu 4985) 解题报告
  3. html5--4-3 source元素-解决浏览器的兼容
  4. linux应用之vsftp服务的安装及配置(centos)
  5. HDFS副本设置——默认3
  6. Python下使用Psyco模块优化运行速度
  7. TFS独占签出代码
  8. docker集群管理
  9. IOS远程推送证书的制作步骤
  10. HDOJ-2045