Crystal Reports:在这种情况下如何避免嵌套子报表?

发布于 2024-09-10 23:44:38 字数 2461 浏览 2 评论 0原文

我有一个包含用户信息的主报告,以及一个包含所述用户的多个项目的子报告。

问题是,我需要将主报告根据输入数据源的用户数量进行多次复制 - 我该如何做到这一点,以便生成一份大型报告(包含主报告的多个倍数)?

编辑:让我用一个具体的例子重新提问(类似于我自己的例子):假设我想要一份杂货购物者的报告 - 然而,所有购物者的人口统计数据都将出现在主报告中,需要有一个包含所有购买商品的特定购物行程的部分(或子报告)。

现在,这是咬牙切齿的。我需要针对许多不同的购物行程运行此报告(这也意味着不同的购物者)。

甚至可以说这是一份“购物行程”报告,可以运行一批购物行程。

进一步进展:当我的数据如下所示时,如何进行分组:

(shoppingTripId, shopperId, shopperName, shoppingDate, itemBought)
------------------------------------------------------------------
1, 1, Chris, July-24-2009, Computer
1, 1, Chris, July-25-2009, Laptop
2, 3,  John, June-14-2009, Ipod
2, 3,  John, June-14-2009, Television

如果一切顺利,报告将如下所示:

+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------

目前,我得到的是:

+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------

I have a main report which contains user information -- and a subreport that contains multiple items for said user.

Question is, I need the main report to duplicate as many times as necessary for the number of users I feed into the DataSource -- how can I do this, so that it results in one large report (containing multiples of the main report)?

EDIT: Let me re-ask with a specific example (similar to my own): Let's say I want a report for a grocery shopper -- all of the shopper's demographics would be on the main report, however, there needs to be a section (or subreport) for a specific shopping trip containing all items purchased.

NOW, here is the clencher. I need to run this report for many different shopping trips (this also means different shoppers too).

It might even be better to say that this is a "shopping trip" report, which can run for a batch of shopping trips.

FURTHER PROGRESS: How can I get the grouping to work when my data looks like this:

(shoppingTripId, shopperId, shopperName, shoppingDate, itemBought)
------------------------------------------------------------------
1, 1, Chris, July-24-2009, Computer
1, 1, Chris, July-25-2009, Laptop
2, 3,  John, June-14-2009, Ipod
2, 3,  John, June-14-2009, Television

The report, if all goes well, would look like this:

+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------

At the moment, I'm getting this:

+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| Chris                     ShoppingTripID: 1
| 123 Main Street               CustomerID: 1
| Anytown, CA 90210
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| John                      ShoppingTripID: 2
| 123 Main Street               CustomerID: 3
| Anytown, CA 90210
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
| Computer   $999.00
| Laptop    $1099.00
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------
| Ipod       $999.00
| Television $1099.00
+-----------------------------------------------

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海夜未眠 2024-09-17 23:44:38

将主报表移至报表的详细信息中(如有必要,可将其分成小节以进行格式化),并将子报表也放入详细信息中。

这样,您将获得每个用户的主报告(以及子报告)。

编辑

我想得越多,您可能甚至不需要子报表。如果您在主报告中将购物者表和购物行程表合并在一起,则可以将购物行程信息放入详细信息中,所有信息均按购物者 ID 分组。

在组标题中,您将放置主报告中当前的所有内容。

从这里,您可以将购物行程 ID 列表作为参数传递给报告,并在记录选择公式中使用此参数。

你最终应该得到这样的结果(编辑 2010/07/25):

+-----------------------
| Report Header 
+-----------------------
| Page Header
+-----------------------
| Group Header (Grouped by **ShoppingTripID**)
|   Display your shopper information here
+-----------------------
| Details
|   Display your shopping trip information 
|   for the shopper here
+-----------------------
| Group Footer
+-----------------------
| Page Footer
+-----------------------
| Report Footer
+-----------------------

Move the main report into the details of the report (broken up into subsections for formatting if necessary), and place the subreport into the details as well.

That way, you'll get a main report (plus subreport) for each user.

Edit

The more I think about it, you probably don't even need a subreport. If you join your shopper and shopping trip tables together in the main report, you can put the shopping trip information in the details, all grouped by the shopper ID.

In the group header, you'll put everything that is currently in your main report.

From here, you can pass the report a list of shopping trip IDs as a parameter, and use this parameter in your Record Selection Formula.

You should end up with something like this (edited 2010/07/25):

+-----------------------
| Report Header 
+-----------------------
| Page Header
+-----------------------
| Group Header (Grouped by **ShoppingTripID**)
|   Display your shopper information here
+-----------------------
| Details
|   Display your shopping trip information 
|   for the shopper here
+-----------------------
| Group Footer
+-----------------------
| Page Footer
+-----------------------
| Report Footer
+-----------------------
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文