日期:2014-05-17 浏览次数:21389 次
先看看设计的报表样式:

?reportTitle是新添加的一个参数,而其他的id和name是通过数据源得到的Filed。IReport在设置参数的时候需要先在左边新建一个parameter,然后再把该parameter托到右边的设计栏中。
?
生成的XML文件为:
<?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="report3" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[select * from t_blog;]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<field name="content" class="java.lang.String"/>
<field name="postTime" class="java.sql.Timestamp"/>
<field name="seenCount" class="java.lang.Integer"/>
<field name="title" class="java.lang.String"/>
<field name="blogStore" class="java.lang.Integer"/>
<field name="owner" class="java.lang.Integer"/>
<field name="sysCategory" class="java.lang.Integer"/>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="44" splitType="Stretch">
<staticText>
<reportElement x="227" y="12" width="100" height="20" forecolor="#FF0000"/>
<textElement textAlignment="Center">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[标题]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="35" splitType="Stretch">
<staticText>
<reportElement x="227" y="15" width="100" height="20" forecolor="#FF0000"/>
<textElement textAlignment="Center">
<font size="13" isBold="true"/>
</textElement>
<text><![CDATA[页眉]]></text>
</staticText>
</band>
</pageHeader>
<columnHeader>
<band height="40" splitType="Stretch">
<staticText>
<reportElement x="70" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[id]]></text>
</staticText>
<staticText>
<reportElement x="214" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[title]]></text>
</staticText>
<staticText>
<reportElement x="373" y="2" width="100" height="20"/>
<textElement/>
<text><![CDATA[postTime]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="81" splitType="Stretch">
<textField>
<reportElement x="70" y="24" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="214" y="25" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{title}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="373" y="26" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{postTime}]]></textFieldExpression>
</textField>
</band>
</detail>
<columnFooter>
<band height="40" splitType="Stretch">
<staticText>
<reportElement x="227" y="10" width="100" height="20" forecolor="#FF0000"/>
<textElement textAlignment="Center">