或者你可以做以下的(使用的iReport):
- 添加基於用戶名報告團,不從報告檢查器中添加組標題和頁腳
- 拖放領域進入報表設計器中的細節帶。
- 取消選中在如下圖所示打印重複值
所得報告會像選擇包含用戶名的Text field
,在屬性面板。
附JRXML備查
<?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="report6" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9ecb5f72-ce8e-4b32-bc4b-124460d6d018">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[select * from (
select 'xmen' as username, 'news' as category, 'good' as view
union select 'xmen', 'media', 'good'
union select 'xmen', 'radio', 'bad'
union select 'xmen', 'tv', 'ok'
union select 'Ymen', 'news', 'good'
union select 'Ymen', 'media', 'good'
union select 'Ymen', 'radio', 'bad'
union select 'Ymen', 'tv', 'ok'
) tbl
order by username]]>
</queryString>
<field name="username" class="java.lang.String"/>
<field name="category" class="java.lang.String"/>
<field name="view" class="java.lang.String"/>
<group name="user">
<groupExpression><![CDATA[$F{username}]]></groupExpression>
</group>
<columnHeader>
<band height="20">
<staticText>
<reportElement uuid="6cb3e793-d932-4d29-aca4-3b1efa03a5dd" x="0" y="0" width="185" height="20"/>
<textElement/>
<text><![CDATA[username]]></text>
</staticText>
<staticText>
<reportElement uuid="341be19e-6a83-4b8d-9878-8e2c8760b014" x="185" y="0" width="185" height="20"/>
<textElement/>
<text><![CDATA[category]]></text>
</staticText>
<staticText>
<reportElement uuid="8778300d-b296-41d9-9d12-abda95a80c71" x="370" y="0" width="185" height="20"/>
<textElement/>
<text><![CDATA[view]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="4d88aa40-ee74-4535-99a4-e3aec64188d2" isPrintRepeatedValues="false" x="0" y="0" width="185" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{username}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="c098560e-c140-4b9a-9599-ed0875014c0f" x="185" y="0" width="185" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{category}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="1784b19e-6adb-4d3e-aa04-d172ee39a7cf" x="370" y="0" width="185" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{view}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
@亞歷克斯·K,u能請電話我在哪裏,在報表設計器提供這些功能。 – syncdm2012