在 Crystal Reports 中显示树结构 [英] Displaying a Tree Structure in Crystal Reports

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

问题描述

有人知道在 Crystal Reports 中表示树结构的方法吗?我最大的问题是我不知道树的深度.它以简单的childId -> parentId"关系在数据库表中表示.

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.

一个完美的例子是打开 Windows 资源管理器,然后查看左侧的目录树.如果有人知道代表那棵树的方法,那么它也可以满足我的需要.

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.

我最初的尝试是:

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

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) 递归地将同一报表嵌套到每个级别.换句话说:

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

mainReport
  subReport
    subReport
    subReport
  subReport
  subReport
    subReport

等等……

很遗憾,SubReports 不能包含 SubReports.

Unfortunately, SubReports can't contain SubReports.

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

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 添加了分层分组.您可以在报告"菜单下找到它.我使用它整理了一个具有 n 级深度的快速组织结构图报告.数据库表如下:ID名称管理员ID

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

在 Crystal Report 中,您选择这些列,按 id 分组.然后在 Reports 下的Hierarchical Grouping options"菜单下,勾选Group Data Hierarchically",parent Id 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 中显示树结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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