[Jasper usage summary] iReport report design - overall introduction (2)

There are two kinds of iReport files, one is .jrxml source file (similar to .java), and the other is .jasper compiled file (similar to .class). What we drag and drop in ireport is the .jrxml file. And click the preview to generate the .jasper file.

It is said to be .jrxml, but it is actually an XML file, but this file needs to conform to the xsd format of ireport, and it can also expand its own tags, but the tags defined by itself do not support drag and drop, unless you implement it yourself.

 

Through our designed .jrxml, we can convert a series of data from any data source (such as jdbc, cvs, xml, javabeans, excel, etc.) to the format we want and export to HTML/EXCEL/WORD/PDF/ FLASH and other report files.

 

1. iReport report file - basic properties


 

Classification property name Function description
  report name report name
Page Size
  Page Width page width
  Page height page height
  Orientation Report orientation, which can be horizontal or vertical, the default is vertical for the public
Margins
  Left margin The left end of the page is blank, the unit is px, the default is 20px
  Right margin The right end of the page is blank, the unit is px, the default is 20px
  Top margin The top of the page is blank, the unit is px, the default is 20px
  Bottom margin Blank at the bottom of the page, unit px, default 20px
Columns
  Columns The report is divided into several columns, the default is one column.
  Column Width the width of each column
  Column space white space between columns
  Print order Printing method - vertical/horizontal. Default vertical
More
  Scriptlet class A custom scriptlet to customize some behavior when the report is generated.
  Resource bundle Resource files used in reports, support internationalization
  When Resource Missing Type When the resource property is not found, what is the value? Can be null, blank, error, element's key
  Query Text The SQL query statement can also be set in the DataSet.
  The language for the dataset query The type of SQL statement can also be set in the DataSet. Such as ordinary SQL, Hibernate, MDX, etc.
  Filter Expression Filter the result of the SQL statement query again, write it with ireport expression, the return type must be Boolean type
  Properties Some additional property settings supported by the report
  Title on a new page Whether the Title occupies a single page
  Summary on a new page Whether Summary occupies a single page
  Summary with Page Header and Footer Whether to display Page Header and Page Footer in Summary
  Float column footer
  Ignore pagination Whether to not paginate, the entire report is displayed on one page
  Column Direction Whether the report is displayed left or right
  When No Data
When the Main DataSet records 0, what is displayed? The options are:
1. Everything except Details Band
2. Blank page
3. Display NoData Band (this band can be defined separately for the report, and it is used for information prompt when there is no data)
4. Show nothing
  Language The type of expression of the report: the options are -java, groovy, javascript
  Format Factory Class The formatting scheme of Data and Number types can be customized. This class needs to inherit from the XX class
  Imports Can reference other packages, custom or 3rd party etc. For example org.myself.utils
 
 
 
2. iReport Content - Bands (our artboard)
The content of the entire report is composed of many Bands, and what we have to do is to draw the text, pictures, charts, backgrounds, etc. we want on these Bands.
其实就相当于我们的画布,只不过这个画板有点多,且每个画板的功能也不同,还有一些属性需要设置,综合配置好这些,才能画一副完整的报表图画出来~
 
    a) 每个画板都有3个属性:
Band height band的高度
Print When Expression 当表达式为TRUE时,才显示该Band
Split Type 可设置当内容超过当前Band高度时,是继续显示一部分,还是在新的一页显示完整内容。
1.Immediate 直接显示不完整信息
2.Prevent 到新的一页显示完整信息
3.Stretch 延伸当前页,显示完整信息
     b) 各个画板的功能描述 :
Band Name 功能描述
Title 报表的标题,仅显示一次,可设置为单独占一页。
需注意在这里使用variable时,不能设置其Evaluation Time 为 Now,否则为null
Page Header 每页的头部,在每页都会显示一次
Column Header 每列的头部,一般的情况下,我们将表头设置在这里。
XXX Group Header 当报表中存在Group时,才有此band。显示在每个Group的开始位置。有多少个Group显示多少次。一般将Group Name 显示在这里
Detail 数据明细,每行数据在这里显示。有多少行数据,显示多少次。
XXX Group Footer 当报表中存在Group时,才有此band。显示在每个Group的结束位置。有多少个Group显示多少次。一般将Group 汇总计算信息 显示在这里
Column Footer 每列的底部,一般的情况下,将整个数据明细汇总信息显示在这里。
Page Footer 每页的底部,在每页都会显示一次
Last Page Footer 最后一页的底部,在最后一页才显示一次。
Summary 汇总页,仅在报表最后显示一次,一般将整个报表的汇总信息显示在这里。
No Data 当报表查询记录为0时,可设置显示该Band内容。比如可设置其内容为:“当前查询无数据,如有问题请联系XXXX.”
Background 整个报表的背景,比如我们给整个报表设置一个水印效果
二、DataSet
光有画板是不行的,我们还需要颜料,那就是DataSet,也就是数据源。就有了数据,才能开始加工设计。
iReport支持多个DataSet,默认仅有一个Main Data Set。
iReport支持的查询类型也很多,普通SQL,HQL,MDX Query,Json等等。
另外还可以为JavaBean,这样业务逻辑就可以放入Java 的Service里处理了。
 
Parameters,Fields

Parameters与Fields都来自于外部。一个是外部传入的参数,一个是根据数据源生成的字段(当然也可以字的自定义Fields)
        Parameters 主要由报表外部传入,它默认已经自带了一些系统参数,例如 REPORT_PARAMETERS_MAP,REPORT_DATA_SOURCE,REPORT_MAX_COUNT,REPORT_TIME_ZONE 等。另外也可自定义自己的Parameters,比如统计时间段,组织No等业务参数。
Fields 一般由数据源查询SQL自动生成,一般不用管。它对应SQL/JavaBean中查询出个各个字段名称。
 
四、Variables
Variables类似于方法内部定义的局部变量,方便我们进行计算汇总,以及常量定义等。
        系统自带几个参数:比如当前Page Number,当前Column Number,总Report Count,总Page Count,总Column Count。通过这些自定义参数,我们可以设置一下特殊样式,比如隔行变色等。
        另外,我们还可以自定义一些Var,进行Sum,Avg,Count等计算。因内容较多,后面单独总结吧。
 
五、Elements
画板上可以画啥子东西呢?可以画静态文本,动态文本,JFreeChart图表,Flash图表,HTML5图表,Maps,交叉表,条形码等等各种Elements。甚至我也可以自定义一个组件,用来显示;还可以显示HTML代码;调用JS脚本等。
这里抱怨一下,Chart这种用的JFreeChart的图片效果的图表,是否该废弃了?样子老难看的说~
还有其Charts Pro,Maps Pro,Widgets Pro 3种Flash 报表都是基于Fusionchart实现的,而且是用的免费版Fusionchart,可选择的图表类型实在是太少了...如果能改为 FusionChart收费版,功能该多么强大。只能意淫一下了...
        在4.7以后的版本里出现了HTML5 Charts,估计也是为了弥补Flash Chart方面的不足吗?但是目前来说HTML5 Charts能支持的图表类型也是不多啊
而Spider Chart,还是用的旧的JFreeChart或其自定义实现的一个图片效果的图表,样子要多难看也多难看。(在3.7版本里,甚至都没有这个图表类型,还是自己做了一个插件实现的,效果都比它这个好看。)
好歹是收费版,你不能做的更漂亮,更炫丽,图表类型,功能选择更多一点吗?
还好有了Generic Element和HTML组件,我们可以调用JS,HTML,或Java代码实现自己的组件,但是毕竟要自己动手,而且这样出来的貌似只支持HTML导出呢。
 
 
整个报表基本上就是由这些部分组成了,我们要做的就是根据这些组件或元素,画出我们想要的效果。简要介绍总结完毕~ 又进了一小步

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327031292&siteId=291194637