jasperreport 模板格式 及ireport 设计器

来源:互联网 发布:淘宝卖家如何取消订单 编辑:程序博客网 时间:2024/06/06 01:36

jasperReport介绍:

JasperReport是一个强大、灵活的报表生成工具,能够展示丰富的页面内容,并将之转换成PDF,HTML,或者XML格式。该库完全由Java写成,可以用于在各种Java应用程序

IReport介绍:

iReport 是为JasperReports Library和JasperReports Server设计的报表可视化设计器


通过iReport 设计好模板后,用JasperReport的jar库,可以在项目中使用模板生成各种报表


报表格式介绍


Report Template

以下是图中提到的每个元件的描述。

元素描述title标题包含该报告的标题。它只会出现一次,在报告的一开始,例如,“Yiibai教程报告”。pageHeaderPageHeader可能包含日期和时间的信息和/或组织的名称。这出现在每个页面的顶部。columnHeaderColumnHeader列出了要在报表中显示,例如,“作者姓名”,“启动时间”,“完成时间”具体字段,“工作时间”和“日期”等的名称。detail详细信息在这里显示的特定字段(在的columnHeader列表)条目,例如部分"Manisha", "9:00", "18:00", "9", "10.02.2013".columnFooterColumnFooter可以显示的任何字段的总和,例如,"Total Hours Worked: 180"pageFooterPageFooter可能包含页面计数信息。它出现在每个页面的底部,例如,"1/23".summary摘要包含从“细节”部分推断出的信息,例如,工作小时为每个作者的数量列表,总工时为每个作者可以把视力表像饼图,曲线图等,为更好的比较。

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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ca5579f3-89ba-4d46-a0bf-cc145b2cbe63"><property name="ireport.zoom" value="1.0"/><property name="ireport.x" value="0"/><property name="ireport.y" value="195"/><queryString language="SQL"><![CDATA[select * from link_info]]></queryString><field name="id" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="link_name" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="from_nodenum" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="to_nodenum" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="link_color" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="groupid" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="create_user" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="description" class="java.lang.String"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="usable" class="java.lang.Boolean"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="create_time" class="java.sql.Timestamp"><fieldDescription><![CDATA[]]></fieldDescription></field><field name="road_length" class="java.lang.Float"><fieldDescription><![CDATA[路长]]></fieldDescription></field><background><band splitType="Stretch"/></background><title><band height="79" splitType="Stretch"><staticText><reportElement x="200" y="19" width="189" height="48" uuid="15e5e6c0-de04-42c8-be59-01b1eed01b56"/><textElement textAlignment="Center"><font size="24"/></textElement><text><![CDATA[标题]]></text></staticText></band></title><pageHeader><band height="35" splitType="Stretch"/></pageHeader><columnHeader><band height="61" splitType="Stretch"><staticText><reportElement x="25" y="24" width="84" height="20" uuid="e23a18f1-4876-4436-8f29-a0843c5e99b8"/><text><![CDATA[名字]]></text></staticText><staticText><reportElement x="125" y="24" width="84" height="20" uuid="46e56b60-c779-48b0-8ffc-1b4902a267ac"/><text><![CDATA[来自]]></text></staticText><staticText><reportElement x="251" y="24" width="84" height="20" uuid="9b1579c1-4d51-4566-bb79-98a940aa510a"/><text><![CDATA[连接到]]></text></staticText><staticText><reportElement x="358" y="24" width="84" height="20" uuid="5952fbc3-134a-4bc3-adbc-838f49d21a59"/><text><![CDATA[id]]></text></staticText></band></columnHeader><detail><band height="125" splitType="Stretch"><textField><reportElement x="25" y="10" width="100" height="20" uuid="a412f9d3-6649-4325-8492-c0b9263c691c"/><textFieldExpression><![CDATA[$F{link_name}]]></textFieldExpression></textField><textField><reportElement x="358" y="10" width="100" height="20" uuid="d616d652-8d1b-4d10-a410-4171f40a7989"/><textFieldExpression><![CDATA[$F{id}]]></textFieldExpression></textField><textField><reportElement x="126" y="10" width="100" height="20" uuid="931c21cb-3975-42cb-a087-d94798b6820d"/><textFieldExpression><![CDATA[$F{from_nodenum}.toString()]]></textFieldExpression></textField><textField><reportElement x="251" y="10" width="100" height="20" uuid="9d93f9c6-1838-46cb-8a1f-677540f29e7c"/><textFieldExpression><![CDATA[$F{to_nodenum}.toString()]]></textFieldExpression></textField></band></detail><columnFooter><band height="45" splitType="Stretch"/></columnFooter><pageFooter><band height="54" splitType="Stretch"><textField><reportElement x="399" y="10" width="80" height="20" uuid="907affe4-7cbc-4f03-9d63-8defa94eccf4"/><textElement textAlignment="Right"/><textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression></textField><textField evaluationTime="Report"><reportElement x="493" y="10" width="40" height="20" uuid="f965007e-3b26-4ab9-9147-0fba28cb1d91"/><textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression></textField></band></pageFooter><summary><band height="42" splitType="Stretch"/></summary></jasperReport>


Jaspersoft+iReport+Designer5.6+oracle11g

请看百度经验:

http://jingyan.baidu.com/article/219f4bf7d75f9ede442d38b0.html

在ireport 上选择各种预览方式,点击预览就可以生成各种格式的文件,注意pdf 比较特殊,需要设置 字体格式个中文类型。不然不会显示。

ireport会生成**.jasper和**.jrxml。**.jrxml相当于xml配置文件,里面包括设计的个中字段及数据库查询语句及 报表格式。而**.jasper是*.jrxml编辑过后的二进制文件,不可读。

我们在以后和java项目整合时使用到的是ireport生成的**.jasper文件。当然也可已使用**.jrxml文件,然后在编译成**.jasper文件。



0 0
原创粉丝点击