Birt_报表参数的使用配置说明

Birt 报表参数的使用Birt 是一款非常流行的开源报表开发工具。

本文总结了 Birt 报表中参数机制,并结合实例详细地阐述了参数的各种使用方法,最后介绍了 Birt 报表的源代码级使用。

以期为 Birt 报表使用者提供一个有益的参考。

序言参数是 birt 提供的一种很重要的机制,在 birt 中,参数具有变量的作用,它为 birt 报表的生成提供了一种灵活强大的机制。

本文基于 Birt 2.1.2 讲述 Birt 报表中一些重要的用法以及 birt 源码级的参数使用机理,为报表开发者以及报表应用程序开发者提供一个参考。

本文的示例是基于 Birt RCP designer 2.1.2 开发的,在阅读本文前,最好有 eclipse 相关经验,并且已经能够使用 Birt 插件制作一些简单报表,并了解 Birt 报表的一些基本概念,比如 Data Source(数据源),Data Set(数据集)等。

基本报表制作过程可见 developerworks 相关文章"BIRT:基于 Eclipse 的报表"。

本文示例使用 Birt 自带的 Sample 数据源,用到的数据基于图 1 所示的实体关系模型。

从这个模型中可以看出,文中示例用到三张数据库表分别为 customers,orders 和 orderdetails。

其中 customers 表的customernumber 字段作为外键出现在 orders 表中,而 orders 表的 ordernumber 字段做为外键出现在orderdetails 表中。

图 1. 实体关系模型1 标量参数(Scalar parameter)在使用 BIRT 参数的时候,首先要了解 BIRT 分为报表参数和数据集参数。

报表参数定义于整个报表内,而数据集参数定义于某个数据集(Data Set)中。

数据集参数使用的时候通常需要链接到某个报表参数或者利用绑定表(binding tab)和一个嵌套表中的某个数据元素绑定。

标量参数是Birt报表中最简单也是最基本的一类参数,标量参数可以分为静态和动态两种,其中静态参数从用户界面获得用户输入的数据值,而动态参数则可以关联至某一个数据集,因此可以获得一个数据的集合,供用户选择。

下面分别介绍这两种参数。

1.1 静态标量参数右键点击Outline面板中的Report parameter选项,在弹出的上下文菜单中点击“New parameter”,弹出图2所示编辑参数对话框,在name域输入参数的名字,本例中使用的参数名字为“customernum”,此时List of value项默认为static。

点击OK后返回到开发主界面。

图 2. 编辑参数接下来定义Data Set。

Data Set定义的对话框如图3所示。

在这个对话框中首先定义“Query”。

我们可以看出Where条件中的customernumber字段通过”?”代表的参数传入参数值。

图 3. 数据集中的“查询”定义点击”Parameter”,弹出在数据集中定义参数的对话框。

数据集中的参数需要链接至某一个报表参数。

在本例中将数据集参数链接至前面定义的报表参数customernum。

点击OK,我们就完成了数据集中参数的定义。

当报表运行时,Birt会使用由报表参数customernum传入的值填充where条件,生成结果数据集。

如图4所示。

图 4. 数据集中的“参数”定义1.2 动态标量参数动态参数可以提供一个数据值的列表供用户选择,这种功能能够极大增强报表设计用户界面的交互性。

在本例中,我们首先定义一个数据集,这个数据集不使用参数,它从订单表中查询出所有的订单号,为报表参数提供一个数据值的列表。

如图5所示。

图 5. 数据集“ordernum”接下来,我们定义报表参数,这个参数链接至前面的ordernum,因此可以根据数据集中的参数ordernum动态的获得可选值。

如图6所示。

图 6. 报表参数“ordernumpara”如图中所示参数的display type选成Como Box,List of value选择为Dynamic,其链接至的Data Set选择为前面定义的ordernum数据集,同时选定Select value column为数据集ordernum中的某个字段,这里ordernum数据集只有一个字段,故选择为ordernumber。

这样就将报表参数和数据集参数关联起来。

但这不是我们的最终目的,我们的目的是以报表参数ordernumpara为中介,向另一个数据集提供参数。

因此,我们定义图7所示的数据集。

图 7. 数据集“ordersdetail”点击“Parameter”项,进入数据集参数定义界面,如图8所示。

图 8. 将数据集内的参数连接至报表参数“ordernumpara”将本数据集的参数num链接至ordernumpara,就完成藉由一个报表参数为中介将一个数据集的字段值链接到另一个数据集的参数的功能。

2 Cascading Parameter除了使用动态报表参数提供数据值的选择列表,报表开发过程中用户经常需要用到互相关联的参数。

比如要选择某个客户的某个订单号标识的所有订单的内容,用户并不愿意列出所有可能的订单号,比较理想的情况是给出一个客户编号的选择列表,根据这个列表的内容再给出每个客户的所有订单号的列表,这样用户就可以选择相应的客户对应的某个订单号,从而查询出此客户的这个订单号标识的所有订单的详细内容。

Cascading parameter 一方面增强了报表逻辑的功能;另一方面,通过将一部分应用逻辑转移到界面操作上,进一步降低了报表内部逻辑和SQL查询语句的复杂性。

首先定义一个customer数据集,这个数据集包含customernumber和customername两个字段。

如图9所示。

图 9. 数据集“customer”接着定义一个名字为orders的数据集,如图10所示。

图 10. 数据集“orders”在“Orders”数据集中使用一个数据集参数,这个数据集参数将要引用接下来将要定义的层叠参数中customer参数。

定义了以上数据集之后,我们就可以来定义层叠参数了。

右键点击Outline面板中的Report parameter选项,在弹出的上下文菜单中点击“New Cascading Parameter”,弹出以下对话框,在Cascading Parameter name域输入参数的名字,本例中使用的参数名字为“custorder”,Data Set Model选择为Multi Data Set。

在紧接着的Parameters表中定义一个名为customer的参数,并将其关联至customer这个数据集,其取值为customer数据集中的 customernumber字段,这样customer这个层叠参数的取值就是一个customernumber的列表。

Customer此时也成为一个动态参数。

如图11所示。

图 11. 层叠参数定义1完成customer的定义后,我们紧接着定义另一参数order,方法和定义customer相同,最后order参数和数据集orders关联,其取值为orders数据集中的ordernumber字段。

由于数据集orders的局部参数需要和前面定义的customer参数关联后才能产生数据结果集合,因此,在下一步将数据集orders与参数 customer 完成关联后,order这个层叠参数也将成为一个动态参数,它也成为一个数据值的选择列表,这个列表的值是由某个 customernumber决定的所有可能的订单号。

如图12所示。

图 12. 层叠参数定义2接下来将orders数据集中的参数param1关联至层叠参数customer,如图13所示。

图 13. 关联数据集“orders”中的参数至层叠参数“Customer”最后,定义生成报表的数据集orderdetail,如图14所示。

图 14. 数据集“orderdetail”然后将其局部参数param1关联至层叠参数order,如图15所示。

这样我们就完成了具有Cascading parameter 功能的数据集的定义。

图 15. 关联数据集“Orderdetail”中的参数至层叠参数“Order”从主开发界面中将orderdetail数据集拖拽到主开发面板上就完成了这个简单的报表的制作。

见图16图 16. 层叠定义完成后的主开发界面点击preview,会弹出如图17所示对话框。

从这个对话框中我们可以看到层叠参数customer的数据是customers数据库表中的所有客户,选定一个客户后,层叠参数order的列表将只出现客户TechnicsStoreInc 的所有订单,选择其中一个订单后,就会从orderdetail数据表中选出这个订单号标识的所有订单的详细内容。

图 17. 层叠参数用户界面3 Parameter Group在某些情况下,在创建报表的时候需要提供大量的参数,为了在界面上更加有效地对这些参数进行组织,BIRT 提供了parameter group的功能。

用户可以使用parameter group将相关的parameter组织在一起。

Parameter group的使用比较简单。

首先需要创建一个parameter group。

在outline视图中用鼠标右键点击report parameters标签并选择new parameter group。

创建完parameter group后便可以为其创建parameter。

为一个parameter group创建parameter有两种方式。

一种方式是用鼠标右键点击parameter group标签并选择new parameter创建新的parameter;另一种方式是将已有的parameter添加入parameter group,只需要使用鼠标将所需要的parameter拖拽入parameter group中。

如图18所示是parameter group 的一个例子。

图 18. Parameter Group示例4 使用parameter实现nested tables前面的例子展示了如何将BIRT中的report parameter与data set parameter进行binding。

作为BIRT parameter的另一个例子,我们下面通过介绍data set parameter与data colummn的binding实现nested tables。

本节将通过JDBC Dataset和Scripted Dataset分别介绍实现过程。

合集下载

BIRT3.72汉化版开发使用说明

BIRT3.72汉化版开发使用说明

1简介1.1BIRT (Business Intelligence and Reporting Tools), 是为Web 应用程序开发的基于Eclipse 的开源报表系统,以Java 和J2EE 为基础。

1.2BIRT功能支持:列表-列表是最简单的报表。

图表-当需要图表表现时,数字型数据比较好理解。

BIRT 也提供饼状、线状以及柱状图标等。

交叉表-交叉表(也叫做十字表格或矩阵),分组分类统计。

导出和打印支持。

1.3BIRT 有两个主要组件:基于Eclipse 的报表设计器,以及部署到应用服务器上的运行时组件(ReportEngine报表引擎和WebViewer网页浏览器)。

2birt报表设计器eclipse-reporting-indigo-SR2-win32用于开发和制作rptlibrary库文件和rptdesign报表文件,设计器制作完成的文件,不能用其他工具如记事本、UE去修改(可以查看),一旦修改则原文件作废。

3birt运行器3.1birt运行器有两种,一种是最基本的ReportEngine报表引擎,可以直接用java编程配置和调用,导出多种格式;一种是WebViewer网页浏览器,内置了ReportEngine,只需要提供报表文件和参数,即可直接网页iframe的方式展示报表内容。

3.2基本部署:birt-runtime-3_7_2整个放入tomcat下的webapps中,如果不需要web展示,可以只保留ReportEngine和report文件夹。

如果需要web展示,可以删除ReportEngine文件夹。

如果都需要,删除ReportEngine文件夹,并将java调用API时的birtHome路径配置为birt-runtime-3_7_2下的WEB-INF文件夹即可。

可以变更birt-runtime-3_7_2文件夹的名称。

3.3在birt报表中,中文参数值是乱码的解决办法:1.页面打开url使用window.open(encodeURI(url));2.修改tomcat--->conf---->server.xml,添加<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"URIEncoding="UTF-8" useBodyEncodingForURI="true"redirectPort="8443" />4birt 库文件开发制作4.1运行birt报表设计器,初次使用时,新建一个报表项目,以进入报表设计模式。

Birt使用手册范本

Birt使用手册范本

Birt使用手册1.1简介BIRT 是一个Eclipse-based 开放源代码报表系统。

它主要是用在基于Java 与J2EE的Web 应用程序上。

BIRT 主要由两部分组成:一个是基于Eclipse 的报表设计和一个可以加到你应用服务的运行期组件。

BIRT 同时也提供一个图形报表制作引擎。

BIRT 拥有和Dreamweaver 一般的操作界面,可以像画table 一样画报表,也可以生成图片、导出Excel、html 分页,样式比script 设置简单,另外BIRT 还有OLAP 导航功能。

1.2基本概念数据源:数据的来源,或提供者。

如xml 数据源、jdbc 数据源等。

数据集:数据集合,它必须与数据源关联,可以理解为查询的结果。

报表以及报表项,报表可视为是针对一组数据集的表现形式,而报表项这是这个表现形式的某个具体的单元。

它们之间的关系,与窗体和控件的关系非常类似。

报表、数据集、数据源三者间的关系:数据源 --- 数据集 --- 报表。

报表参数:查询参数的表现形式,使用它可以构建更灵活的报表。

模板和库:主要用于复用报表设计,提高报表开发的效率。

1.3Birt报表设计器的安装与配置BIRT 的下载地址是:/birt/downloads/ 有两种下载方式:1) All-in-One 版本(birt-report-designer-all-in-one-2.2.2.zip),它包含了运行BIRT系统所需的组件,可直接应用。

2) Framework 插件版本(birt-report-framework-2.2.2.zip),安装的必要环境为Java1.4.2/1.5 JDK/JRE; Eclipse SDK 3.2, GEF 3.2 and EMF 3.2。

安装步骤如下:打开eclipse 文件夹,在文件夹中再新建一文件夹(如:birt),然后打开birt-report-framework-2.2.2.zip 把其中的eclipse 文件夹放入新建的birt文件夹中。

【BIRT资料】BIRT运行时参数说明

【BIRT资料】BIRT运行时参数说明

摘自the BIRT Report Viewer•••••••OverviewThe sample BIRT viewer is optimized for use within Eclipse for the preview operation. When used outside Eclipse, it simply acts as an example of the application you might build to run and view reports. Your report viewer application must be in Java so that it has access to the BIRT engine.The Viewer performs three distinct operations, of which one is internal and not visible to your application:•Create a parameter entry form based on the parameter definitions within the report design file.•Given a set of report parameter values, run a report and return the output as either HTML or PDF.•Retrieve an embedded image, or an image of a chart within the report. (Internal operation.)You can use a full-feature Viewer frameset that displays a parameter form and runs the report. Or, you can supply the parameter values and simply run the report to produce a simple HTML or PDF output page.Viewer OperationsThe BIRT viewer provides a number of URLs that control its behavior. The Viewer provides two modes of operation as given by two servlet mappings.Operation Descriptionframeset Display a frameset that has one frame that prompts the user for parameters, then displays the resulting report in another frame.run Runs the report and displays the output as a stand-alone HTML page, or as a PDF document.The servlet mapping names are case sensitive. Run a ReportThe run servlet mapping runs a report given a set of report parameters, and returns the report as an HTML page or PDF document. This servlet mapping does not provide a frameset. Use this option if you want the report to appear as a stand-alone page. Parameters must be handled in one of three ways:•The report requires no report parameters.•Your application already knows the values of the parameters (perhaps from a server session), and passes them along.•Your application has created a parameter page specifically for the report.The run report URL is of the form:;option2=value2;...See below for a list of available viewer command options.Viewer FramesetThe viewer command provides additional UI to work with a report. Use this URL when your report contains parameters, and you want the Viewer to display a UI so the user can enter parameter values. (You should use the run command if the caller already has the parameter values.)The frame-based viewer displays a frameset that contains three frames:• A left-hand navigation frame that contains the report parameters.• A right-hand content frame that contains the report output• A top toolbar frame that contains the navigation bar.The parameters frame displays a form for entering the parameters (if any) for a report. It contains a Run Report button that runs the report. The report then appears in the report frame . The user can refine the report simply by modifying parameters in the parameter frame and again by clicking Run Report.The toolbar contains a button to maximize the report. When this is done, the frameset switches to display a single frame that contains the report output.The viewer URL is of the form:;option2=value2;...See below for a list of available command options. The command options allow you to control which of the three frames appear in the resulting web page.When you issue this command, the viewer will do one of two things:•Run and display the report if it has no parameters, or•Display the parameter page and ask you to enter parameters. You can then click the Run Report button to run the report.Viewer Command OptionsThe run and the frameset Viewer operations both take a set of options which include report parameters. Report parameters are defined within the report design. They appear in the URL using their internal names, not display names. Viewer options pass information to the BIRT Viewer web app. Viewer options start with a double underscore to differentiate them from report parameters. Option names and values must be encoded for use in a URL. For example:In the above:•– The URL (including port) for your installation of the app server.•/birt-viewer/ – The name of the BIRT Viewer servlet.•run – The servlet mapping for running a report.•report% – Relative file system path of the report to run. The name is relative to the web app directory in which the birt-viewer was installed.•OrderNumber=10010 – The name and value of a report parameter as defined in the report design.List of OptionsThe available viewer options include:Option Description Values Default frameset run __format The output format html or pdf html Y N__isnull Identifies that a reportparameter has a nullvalueParameter name None. Required. Y Y__locale Report locale Java locale valuesuch as en, en-us orch-zh.JVM locale Y Y__report The absolute path tothe report document.None. Required. Y YreportParam Report parameter. As specified in thereport design.As specified inthe reportdesign.Y YCase-SensitivityCase-sensitivity of the options varies:•Viewer option names and values are case-insensitive.•Report parameter names are case-sensitive: they must match the name as defined in the design.•The file name case sensitivity is defined by your operating system.If the URL contains a misspelled option name, or the name of report parameters are in the wrong case, then the Viewer silently ignores the parameter.The __format OptionThe type of output to produce: either html or pdf. Values are case insensitive. If a value other than pdf is provided, then the HTML format is produced.The __isnull OptionReport parameters can take a value, or can be null. (Here "null" means the database definition: the value is unknown.) By definition, date and numeric report parameters have a null value if the report parameter is provided in the URL, and the value is blank. However, string report parameters have an ambiguity: is an empty value to be considered blank (a string whose value is ""), or null? Since blank is used more often, BIRT interprets an empty report parameter value as blank. To say a string parameter is is null, just write:__isnull=yourParamWhile this option is primarily for string report parameters, it works just as well for other report parameter types as well. See the section below for additional details.The __locale OptionUse the __locale option to specify both the locale for report parameter values, and the locale for the report output. The locale must be a valid Java locale such as en-us, etc. as specified in the . If you do not specify a locale, it defaults to the locale set in the Java virtual machine (JVM.)Values are case insensitive.The __report OptionThe __report Option names the report design to run. It can be an absolute or relative file name. If relative, the looks in the directory specified in the BIRT_VIEWER_REPORT_ROOT property in the viewer's file. The file search rules are:•If name is absolute, use it directly.•If BIRT_VIEWER_REPORT_ROOT is set, use this value as the base for the relative name.•Otherwise, use the viewer web app's directory as the base for the relative name. Report ParametersReport parameters can be Boolean, Number, Date, Float or String. The values are defined as follows:DataTypeValue Encoding NotesBoolean true, false Must use the value true for a true value, all other values (including 1) are treated as false. (Uses the Java () method for parsing.) Values arecase-insensitive.Number Floating point number witha locale-specific decimalseparator.Must not include a thousands separator, or extracharacters such as a currency symbol. Uses the Javaclass to parse the number.String NoneDate Locale-specific dateformat.Uses the Java class to parse the date.Report Parameter ValueThe rules for a given parameter foo are determined by the first rule below that takes effect:•If __isnull=foo appears in the URL, foo's value is null.•If foo=mumble appears in the URL, foo's value is mumble.•If foo= appears in the URL, foo's value is blank if it is a string, and null if it is a number or date.•If foo has a default value, foo's value is that default value.•Otherwise, foo's value is blank for string or null for number and date.Value CheckingThe report definition provides two properties for report parameters that influence parameter validation. First, the allowNull property determines if a report parameter can be null. If a report parameter has a null value, but the allowNull property is false, then the BIRT report engine will raise an error.Second, string report parameters have a allowBlank property. If report parameter has a blank value, and allowBlank property is false, then the BIRT report engine will raise an error.Error ReportingIf an error occurs during the operation, an error page will appear.。

birt_report基础

birt_report基础

Birt基础(report报表简单设计)先下载eclipse的eclipse-reporting-galileo-SR1-win32.zip(制作报表eclipse插件)1、新建一个java project2、在这个project上新建一个report的文件如图:3、创建数据源:(在此用JDBC的数据源,并命名为student)4、创建数据连接,选择Driver Class用jdbc的Driver输入Driver URL、用户名和密码,如果在选择Driver Class时没有jdbc的Driver那点击Manager Drivers把Jdbc的jar包加载进来5、创建Data sets(可以看成是结果集)在JDBC Data Source处先可用的数据源,也就是刚创建的student数据源;选择Data Set Type 结果集的类型,这里就选择了SQL Select Query;输入Data Set Name(结果集的名称)这里输入为student写sql语句使这个结果集是可用的,下图左面显示的是可用的表,在右面输入框内输入相应的sql语句来对应这个结果集点击Finish完成结果集的创建6、现在就可以把这个结果集中的数据按照我们需要的方式显示出来了,点击eclipse窗口左面的Palette选项选择相应控件,有些控件是可以直接接收数据源的如table、Grid……,现在把一个table拖到右面的.rptdesign文件中,拖过来的时候会弹出来下图的对话框,输入columns(字段数)也就是要显示出来的字段,想显示出多少字段就输入几,选择Data Set (选择结果集)在这里就选择刚刚创建的student结果集7、选择左面的Data Explo选项,把要显示出来的选择拖到右面table中的相应位置,如图:点击下面的preview就可以看到相应的结果了:下面的结果显示出来本来是没有边框也不会居中对齐的,要设置相应的样式之后才会这样的,设置样式和css是一样的,选中这个table右击,选择style中的new style只要在里面设置border和text block 就可以了;在本数据库设计中是把sex性别这个值放在数据字典里的,在这里只能显示出1或2,当然要想显示成男或女也是有办法解决的,那就要涉及到子报表功能。

01-Birt工具数据报表开发手册

01-Birt工具数据报表开发手册

Birt数据报表开发手册1. 创建模板双击BIRT应用程序以启动Birt报表设计环境,首次启动未加载任何报表开发资源。

主界面如下:根据报表设计的需要,Birt本身提供了一些常规的模板:当然,也可以根据实际需要,添加一些使用频率比较高的模板。

下面将以两张图形,一张列表,且图形在上横向排列的模板为例,创建新模板。

点击文件菜单中的新建,选择新建模板,根据实际情况修改模板名称和存储路径:为此模板添加一些附加属性,如该模板的描述信息和模板布局的预览图像等。

点击完成,开始编辑此模板的布局。

在组件按钮区域依次选取:一个标签,用于放置报表的标题,双击输入标题文本。

也可根据需要动态的文本。

一个网格:用于放置水平的两张图形,因此网格设置为2列1行。

可根据实际情况调整。

一张表:用于放置数据报表,明细数据列设置为8列1行。

可根据实际情况调整。

关于组件的使用,将在后面的章节中具体说明。

用鼠标右击网格中的其中一个空白处,依次选择插入,图表。

在弹出的对话框中选取需要的图形。

同样的方法处理另外网格的另外一个。

有关图形的制作,将在图形报表开发手册中详细说明。

设置每种组件的属性,在OutLine窗口中选中已经拖放的组件,根据需要对其相应的属性进行调整。

如字体大小,颜色,对齐方式,样式等设置完成后,模板样式如下:保存模板的配置信息,以便在以后的报表开发中可以直接读取该模板。

2. 新建共享资源库在Birt的资源管理器中添加一些共享资源,如共享库:在弹出的对话框中输入Library库文件的保存路径和名称:确定后,Library库的创建完成。

如果操作无误,可以在对应的目录下浏览到新建的库。

3. 新建数据源在共享库中新建一个制作报表需要的数据库连接,以Oracle9i数据库连接为例,需要先配置数据驱动(数据库的驱动程序配置方法已经在报表设计器的配置手册文档中体现)。

然后在新建的库中,用鼠标右击数据源,选择新建数据源:在弹出的对话框中选择对应数据源类型,并为该数据源命名:选择正确的数据库驱动和URL后,就可以进行数据库的连接测试:可以根据报表需要,创建一个或者多个数据源的配置:数据源创建完成后,可以通过选择选择资源管理器中共享资源,Library库下新建的数据源,右击鼠标选择添加到报表,将新建数据源添加值报表中供使用。

birt scriptdatasource传递参数

birt scriptdatasource传递参数

birt scriptdatasource传递参数Birt是一款强大的开源业务智能报表工具,它提供了很多功能和特性来满足不同业务需求。

其中,ScriptDataSource是Birt报表设计中常用的数据源类型之一,而参数传递则是Birt报表设计的重要组成部分。

本文将讨论如何使用Birt ScriptDataSource传递参数。

首先,我们需要理解什么是Birt ScriptDataSource。

ScriptDataSource是一种自定义的数据源类型,它允许我们通过脚本来定义和执行数据查询。

与常规的数据源不同,ScriptDataSource的查询可以通过动态的、自定义的脚本来完成。

这使得我们可以在报表运行时动态地生成查询语句,从而满足更加复杂的数据需求。

要在Birt中使用ScriptDataSource传递参数,我们需要执行以下步骤:1. 创建数据集(Data Set)首先,我们需要创建一个数据集来定义数据的结构和查询。

可以在报表设计的“数据”选项卡中创建数据集。

2. 选择ScriptDataSource在数据集的属性设置中,选择“Scripted Data Source”作为数据源类型。

这样,我们就可以使用自定义的脚本来定义数据源。

3. 编写JavaScript脚本接下来,我们需要编写JavaScript脚本来定义和执行数据查询。

可以在数据集的脚本选项卡中编写脚本。

4. 添加参数在脚本中,我们可以定义参数来传递给数据查询。

通过添加参数,我们可以动态地设置查询条件。

可以使用以下代码来定义一个参数:```params["parameterName"] = value;```在value中,我们可以使用动态的值来设置参数,例如从报表参数中获取的值、计算的结果等等。

5. 执行数据查询在脚本中,我们可以通过查询语句来获取数据,并将结果存储在数据集中。

可以使用以下代码来执行查询并将结果存储在数据集中:```var resultSet = /*执行查询的代码*/;resultSet.getRowSet().setDataSource(dataset);dataSet.setRowSet(resultSet.getRowSet());```6. 使用参数传递数据在JavaScript脚本中,我们可以使用定义的参数来传递数据。

birt报表初级教程之嵌套报表

birt报表初级教程之嵌套报表嵌套报表嵌套报表其实是一种设计技巧的应用,类似编码过程中的模块化设计。

当报表的复杂程度让设计者开始觉得逻辑混乱的时候,可以使用嵌套报表设计方法,将报表拆分为多个不同的设计页面,然后使用一个总的页面将这些设计页面整合起来展现。

此外,嵌套报表有时候也会用于主从结构的实现,通过逐层嵌套,可以实现无限层次的主从结构数据展现。

本例,我们将每个客户的信息包括客户表中基本的信息以及他们的订单信息,在同一张表中按客户一一列出来,所使用的就是嵌套报表。

报表名我们定为:nestingTab.rptdesign构建数据源本例我们使用BIRT自带的数据源,在新建数据源选择数据源类型为默认的第一项:Classic Model Inc,Sample Database数据库驱动类别;org.eclipse.birt.report.data.oda.sampledb.Driver(ClassicModels Inc.SampleDB Driver);URL:jdbc:classicmodels:sampledb构建数据集本例我们需要建立2个数据集:1.建立数据集payments,所用SQL语句:(这里我们加入条件选择订单大于150000)select CUSTOMERNUMBER,sum(AMOUNT)amountfrom CLASSICMODELS.PAYMENTSgroup by CUSTOMERNUMBERhaving sum(AMOUNT)>150000order by amount desc2.建立数据集customers:所用SQL语句:select*from CLASSICMODELS.CUSTOMERS whereCLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER=?输入SQL语句后,还要在数据集编辑窗口选择Parameters选项。

双击默认参数Pram1或者选择“Edit”,弹出如下窗口:输入:Name:CustID;Default Value:103;其它默认完成后,在Preview Result选项中就可看见结果预览:布局嵌套报表1.同上例,先在布局编辑器中建立一个1列2行的Grid。

birt文档

一、去掉Birt表格下自动生成的日期时间在报表下点击Xml Source标签,打开xml,找到&lt;page-setup&gt;&lt;simple-master-page name=&quot;Simple MasterPage&quot; id=&quot;2&quot;&gt;&lt;page-footer&gt;&lt;text id=&quot;3&quot;&gt;&lt;propertyname=&quot;contentType&quot;&gt;html&lt;/property&gt;&lt;text-propertyname=&quot;content&quot;&gt;&lt;![CDATA[&lt;value-of&gt;newDate()&lt;/value-of&gt;]]&gt;&lt;/text-property&gt;&lt;/text&gt;&lt;/page-footer&gt;&lt;/simple-master-page&gt;&lt;/page-setup&gt;把&lt;text id=&quot;3&quot;&gt;&lt;propertyname=&quot;contentType&quot;&gt;html&lt;/property&gt;&lt;text-propertyname=&quot;content&quot;&gt;&lt;![CDATA[&lt;value-of&gt;newDate()&lt;/value-of&gt;]]&gt;&lt;/text-property&gt;&lt;/text&gt;这几行去掉即可。

05-Birt工具图表组合型报表开发手册

图表组合型报表开发指南-----伊朗演示1、新建报表运行Birt报表开发工具后命名,选择保存的目录,然后Finish。

2、新建数据源开发工具的菜单栏,打开Outline窗口:如下:右击数据源,选择新建:如上图选择,数据源名称自定,Next:从“驱动程序类”的下拉列表中选择对应数据库的的驱动,若没有需要的,则选择“Manage Drivers”按钮:将对应数据库的驱动程序添加进来,回到上一步选择驱动程序类:输入数据库连接信息:URL::jdbc:oracle:thin:@10.40.200.69:1521:osstestUser:bi71Password:smart可测试:右击“数据集”,选择“新建数据集”上面选择前面新建的数据源Next:主数据集sql:select B.PROVINCE_NAME PROVINCE,C.PACKAGE_TYPE_NAME PACK,COUNT(1) TOTAL_SUBS,SUM(CASEWHEN A.STATE = 0 THEN1ELSEEND) AS CHRUN_SUBS,SUM(CASEWHEN A.STATE = 1 THEN1ELSEEND) AS NEW_SUBS,SUM(CASEWHEN A.STATE = 1 THEN1ELSEEND) - SUM(CASEWHEN A.STATE = 0 THEN 1ELSEEND) AS INCREASE_SUBS, SUM(CASEWHEN A.IN_STATE = 1 THEN1ELSEEND) AS SILENCE_SUBS,SUM(CASEWHEN A.IN_STATE = 2 THEN1ELSEEND) AS USAGE_SUBS,SUM(D.TARGET_VALUE) AS TARGET_SUBS, (SUM(CASEWHEN A.STATE = 1 THEN1ELSEEND) - SUM(CASEWHEN A.STATE = 0 THEN1ELSEEND)) / COUNT(1) AS INCREASE_RATEfrom f_width_call A, D_PROVINCE B, D_PACKAGE_TYPE C, TMP_SUBS_TARGET DWHERE A.Province = B.PROVINCE_IDAND A.Package_Type = C.PACKAGE_TYPE_IDAND A.PROVINCE = D.PROVINCE_IDAND A.PACKAGE_TYPE = D.PACK_TYPE_IDAND (substr(A.PRD_ID,1,6)=? or ? is null )AND (A.Province = ? or ? is null )GROUP BY B.PROVINCE_NAME, C.PACKAGE_TYPE_NAME3.2、从数据集(对应Month的查询条件)同样新建数据集:Next:Month条件的sql:select distinctto_char(to_date(D_TIME_PERIOD.PRD_ID,'yyyy-MM-dd'),'yyyyMM') AS Y_M from D_TIME_PERIOD3.2、从数据集(对应Province的查询条件)同样新建数据集:Next:Province条件的sql:select prov.PROVINCE_ID ,prov.PROVINCE_NAMEfrom D_PROVINCE prov4、创建报表参数报表参数,即为查询条件的输入参数。

开源报表_BIRT_开发_手册_2

List list = new ArrayList(); list.add(emp1); list.add(emp2); list.add(emp3);
return list; }
}
Birt 报表 开发手册
第 11 页共 44 页
4.2.2 java 类与报表交互
Birt 报表 开发手册
1. 创建报表。在前面已经讲过怎么创建报表,在这里只要选择报表存放目录为工 程的 WebContent。如图:
可以使用 Java 来编写一些事件处理程序并使用 JavaScript 来编写另一些事件处理 程序。如果同一个事件同时有 Java 和 JavaScript 事件处理程序,则 BIRT 将使用 JavaScript 处理程序。
4.1 avascript 脚本编写
4.1.1 隔行高亮度显示
1. 在布局(Layout)中,选择 Table-Detail 的行。如下图:
props = new java.util.Properties( ); props.load(fin); }
extensionProperties.odaURL = new String(props.getProperty("dbURL")); extensionProperties.odaDriverClass = new String(props.getProperty("driverName")); extensionProperties.odaUser = new String(props.getProperty("userName")); extensionProperties.odaPassword = new String(props.getProperty("password"));
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档