JasperReport教程 第10课 JRXML报表模板元素讲解5
继续上节课的内容,讲解jrxml文件的元素
detail元素定义了报表的详细内容部分,即报表的主体部分。detail部分会循环显示报表数据源中的每条记录。
注意:一个jrxml模板文件只能包含0个或1个detail元素。大部分的模板文件都包含一个detail元素。
例子:
<detail> <band height="20"> <textField> <reportElement x="10" y="0" width="600" height="20" /> <textFieldExpression class="java.lang.String"> <![CDATA[$F{FieldName}]]> </textFieldExpression> </textField> </band> </detail>
columnFooter定义了列尾内容。和columnHeader一样,如果报表只有一列内容的话,则会忽略columnFooter。
一个jrxml模板文件可以包含0个或者多个columnFooter元素。当然,如果要包括columnFooter元素,则columnFooter元素的数量一定要和实际的列的数目相等。
例子:
<columnFooter> <band height="20"> <staticText> <reportElement x="0" y="0" width="200" height="20"/> <text> <![CDATA[Column Footer]]> </text> </staticText> </band> </columnFooter>
pageFooter定义的页尾的内容,显示在每个报表页的底部。
一个jrxml模板文件可以包括0个或1个pageFooter元素。
例子:
<pageFooter> <band height="20"> <staticText> <reportElement x="0" y="5" width="200" height="20"/> <text> <![CDATA[Page Footer]]> </text> </staticText> </band> </pageFooter>
lastPageFooter定义了最后一页的pageFooter,也就是说,如果定义了此元素,则最后一页的底部会显示lastPageFooter元素的内容,而不再显示pageFooter元素的内容。lastpageFooter元素,只在最后一页起作用。
一个jrxml模板文件可以包括0个或1个lastPageFooter元素。
例子:
<lastPageFooter> <band height="20"> <staticText> <reportElement x="0" y="5" width="200" height="20"/> <text> <![CDATA[Last Page Footer]]> </text> </staticText> </band> </lastPageFooter>
summary元素的内容会在报表的最后显示一次。
一个jrxml模板文件可以包括0个或1个summary元素。
例子:
<summary> <band height="20"> <staticText> <reportElement x="0" y="5" width="200" height="20"/> <text> <![CDATA[Summary]]> </text> </staticText> </band> </summary>
当报表数据源为空时会报表中会显示出noData元素中的内容。
例子:
<noData> <band height="20"> <staticText> <reportElement x="0" y="5" width="200" height="20"/> <text> <![CDATA[No data found]]> </text> </staticText> </band> </noData>
附一个图,可帮助理解各个元素在报表中的位置。以后使用ireport时,会更加直观的看到各个元素的位置。

看了很久,嗯,每天更新,而且内容不错,很好啊