需要在iReport中创建count变量 [英] Need to create count variable in iReport

查看:760
本文介绍了需要在iReport中创建count变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在iReport中找到一个字段的计数。例如,我需要创建一个名为CallCount的变量,该变量具有CallType字段的计数。所以我需要使用Piechart的Category部分中的CallType字段和CallCount变量作为度量。因此饼图将显示呼叫类型及其呼叫计数。请帮助我....

I need to find the count of a field in iReport. For example i need to create a variable called "CallCount" which have count of "CallType" field. So i need to use "CallType" field in Category section of Piechart and "CallCount" variable as measure. So that pie chart will show the call types and its call counts. Please help me on this....

推荐答案

使用子数据集创建饼图:

To Create pie chart with the use of sub dataset:

什么是子数据集?

报告生成基于单个数据源,例如查询,JavaBeans集合或XML文件。使用图表或交叉表,这可能是不够的,或者使用特定查询或通常使用其他数据集检索数据可能更容易。与此类似,您可以使用子数据集提供嵌套在报表中的辅助记录(使用新数据源执行附加查询,甚至使用用于填充主报表的相同连接)。目前,您可以使用子数据集来填充Chart,Crosstab和List元素,但开发人员可以通过创建自定义组件以其他方式使用它。

Report generation is based on a single data source, such as a query, a collection of JavaBeans, or an XML file. With a chart or a crosstab, this might not be sufficient, or it might simply be easier to retrieve data using a specific query or, in general, using another dataset. In a similar vein, you can use a subdataset to provide a secondary record nested within a report (performing an additional query using a new data source or even the same connection that is used to fill the master report). Currently, you can use a subdataset to fill Chart, Crosstab, and List elements, but a developer may be able to use it in other ways by creating a custom component.

您可以在报告中包含任意数量的子数据集。每个都有自己的字段,变量和参数,并且可以根据需要执行查询。数据集记录可以分组在一个或多个组中(例如在主报告中);这些组用于子数据集变量。

You can have an arbitrary number of subdatasets in a report. Each one has its own fields, variables, and parameters and can have a query executed as needed. The dataset records can be grouped in one or more groups (like in a main report); these groups are used in subdataset variables.

子数据集通过数据集运行链接到其元素。数据集运行指定子数据集检索和过滤数据以及处理用于填充元素的行所需的所有信息。

A subdataset is linked to its element by means of a dataset run. The dataset run specifies all the information needed by the subdataset to retrieve and filter data and to process the rows used to fill the element.

创建报告的步骤使用子数据集:


  • 创建一个ireport。

  • 添加一个新的子数据集。

  • Create an ireport.
  • add a new sub dataset.

转到报告检查员 - >右键单击文档 - >添加 - > sub
数据集。

Goto report inspector -> right click on Document -> Add -> sub dataset.

将出现以下窗口。

给出一个名字到子数据集。

give a name to the sub dataset.

iReport允许您从查询中编辑子数据集的查询,排序和过滤选项对话。查询对话框可用于以与主报表相同的方式自动注册子数据集中的字段(即从SQL查询中获取字段)。

iReport allows you to edit the query, ordering and filter options for the subdataset from the query dialog. The query dialog can be used to automatically register fields in the subdataset in the same way as the main report (that is, getting the fields from an SQL query).


  • 点击查询&添加查询。

在数据集的上下文中,组仅用于对记录进行分组,并且报告中没有离散的部分绑定到它们(例如,像与组关联的页眉和页脚带)。主要是,数据集组与变量计算结合使用。

In the context of a dataset, groups are only used to group records and there is no discrete portion of the report tied to them (for example, like the header and footer bands associated with groups). Primarily, dataset groups are used in conjunction with variable calculations.

现在创建了我们的子数据集。

我们需要将它与饼图一起映射。

We need to map it with our pie chart.

Select the pie chart and Right click on it.

右键单击 - >图表属性 - >图表数据

Right Click -> Chart Properties -> Chart Data

首先,必须在子数据集中声明从主报告发送的所有参数(并且具有相同类型)。
选择您的图表或表格并转到其数据集栏,您将找到数据集运行,参数和参数映射。选择它上面的参数。

First of all, all parameters that you send from the main report, have to be declared(and of the same type) in your sub dataset. Select your chart or table and go to its dataset bar, you will find dataset run, parameters and parameter mapping. Select parameters on it.

现在在列表中添加一个参数,你需要在表达式编辑中打开参数选项并从中选择你在Sub中创建的参数数据集,其名称与主报表输入的参数名称相同。
现在你必须再次提到参数的表达式转到参数选项并选择你在Sub Dataset中创建的参数,其名称与主报表输入的参数名称相同。

Now add a paramter into the list for this you need to open the paramter option in expression edit and select the parameter from it which you created in Sub Dataset and whose name is same as the parameter name of main report input. Now you have to mention the expression of the paramter for this again go to parameter option and select the paramter which you created in Sub Dataset and whose name is same as the parameter name of main report input.

现在在同一窗口的详细信息部分中,添加键表达式,值表达式和标签表达式(可选)。

Now in the details section in the same window, add the key expression,value expression and lable expression(optional).

多数民众赞成它。
现在运行报告。

Thats it. Now run the report.

这篇关于需要在iReport中创建count变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆