Reports中显示树结构

Reports中显示树结构

本文介绍了在Crystal Reports中显示树结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道在水晶报表中表示树结构的方法?
我的大问题是我不知道树的深度。它在一个简单的childId - > parentId关系的数据库表中表示。



一个完美的例子是打开Windows资源管理器,左侧。



我最初的尝试是:

$ b。如果有人知道一种表示该树的方法,
$ b

1)以编程方式(在C#中)向报表添加组。很遗憾,您无法创建Group类的新实例,并将其添加到Groups集合。



2)将每个级别的同一报表递归嵌套。换句话说:

  mainReport 
subReport
subReport
subReport
subReport
subReport
subReport

etc ...



不幸的是,SubReports不能包含SubReports。



我真的不想只添加X个组到报表中,我不需要,因为我必须添加固定数量的嵌套组,但在技术上,数据设计可以支持无限深度,即使在实践中,我们看到高达约5级的深度。


解决方案

Crystal XI添加了分层分组。你会在报告菜单下找到这个。我用一个快速组织图表报告与n级深度使用此。数据库表如下:
id
name
managerId



在Crystal报表中,您可以选择这些列,按ID分组。然后在报告下的分层分组选项菜单下,选中分层数据组数据,父标识managerId,并缩进。



输出结果在资源管理器中。


Does anyone know of a way to represent a tree structure in Crystal Reports?My big issue is that I don't know the depth of the tree. It is represented in a database table with a simple "childId -> parentId" relationship.

A perfect example would be to open Windows Explorer, and look at the directory tree on the left side. If anyone knows a way to represent that tree, then it'll work for what I need to do too.

My initial attempts have been:

1) to programatically (in C#) add Groups to the report. Unfortunately, you can't create a new instance of the Group class and add it to the Groups collection.

2) recursively nest the same report into itself for each level. In other words:

mainReport
  subReport
    subReport
    subReport
  subReport
  subReport
    subReport

etc...

Unfortunately, SubReports can't contain SubReports.

I really don't want to just add X number of groups into a report and hide the ones I don't need, because I'd have to add a fixed number of nested groups, but technically the data design can support an infinite depth, even though in practice we see up to about 5 levels of depth.

So, any other ideas?

解决方案

Crystal XI added hierarchical grouping. You'll find this under the Reports menu. I put together a quick org chart report with n-level depth using this. The database table is like: id name managerId

In the Crystal Report, you select these columns, group by id. Then under "Hierarchical Grouping options" menu under Reports, check off "Group Data Hierarchically", parent Id managerId, and indent appropriately.

The output is like the tree you described in Explorer.

这篇关于在Crystal Reports中显示树结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 15:35