Crystal Reports公式及其在不同部分中的运行方式 [英] Crystal Reports formulas and how they run in different sections

查看:71
本文介绍了Crystal Reports公式及其在不同部分中的运行方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览了多份指南,但似乎没有一个关于何时将项目放入组页眉",详细信息"和组页脚"的良好指南.

通常,我的理解是将任何类型的总计放入适当的级别组页脚中,因为页眉首先运行->详细信息->页脚.

我真的很困惑,因为我最近不得不制定一份更复杂的报告.我有三个表-作业主",计费主(由作业号连接)"和成本核算主(由作业号连接)".我为作业主管"作业编号设置了一个组,并尝试从其他每个表格中提取帐单和费用.但是,无论我将信息放在何处(组页眉,详细信息或组页脚),其中某些信息都是错误的.

我们需要尽快获得报告,因此我最终为帐单制作了一个子报表,为成本计算制作了另一个子报表,并使用通用变量将内容从子报表中取出.这效率不高,并且运行时间很长,但是数据正确.我将子报表放在页脚中.

我确定可能有一种更聪明的方法来执行此操作,但是当您从多个数据库中提取字段时,我似乎不太了解如何使用页眉/页脚/详细信息部分.有人有指针吗?谢谢!

解决方案

您的问题有点太广泛了.如果您举报特定案件,我相信您会获得更多帮助.

但是我现在可以说的是,您可能已经认识到了您自己:

  1. 详细信息"部分显示迭代数据.
  2. 页眉和页脚显示非迭代数据(但不包括组页眉和组页脚).

如果您在这些部分中使用正在运行的总计字段",并将它们与汇总字段"进行比较,您会注意到重要的内容.我相信您很困惑,因为您曾期望使用汇总字段"时会出现运行总计字段"的行为,但我只是在推测.

我不知道Crystal Reports是如何实现的,但是这是我的思维模型,可以帮助我了解各节中正在发生的事情.

  1. 假设您有一个包含两个表的报表,并且没有子报表.
  2. 首先,Crystal将加入您的表.联接将取决于您如何设置表之间的链接.如果未正确设置链接,则最终将得到表的笛卡尔积,这可能意味着不希望有的重复行.
  3. 此联接的结果是具有N行的投影".因此,对于每一行,它将打印一个详细信息"部分.
  4. 因此,如果在详细信息部分中放置表格的一个字段(实际上是一列),您将看到打印出来的值,就像您可能期望的那样.
  5. 但是如果您在页面标题中放置相同的字段,它将打印出第一个匹配项.
  6. 但是,如果您在页脚中添加了相同的字段,它将打印最后出现的内容(不确定是否是最后一个出现的内容).
  7. 汇总字段将在迭代行之后进行计算.这意味着它们位于页眉还是页脚中都没有关系-结果相同.因此,如果详细信息部分有10行,其中某列所有行的值均为1,并且您创建了一个摘要字段以对该列求和,则其结果在两个部分(页眉和页脚)中均为10./li>
  8. 正在运行的总计字段将即时计算.因此,如果详细信息部分有10行,其中某列所有行的值均为1,并且您创建了一个运行总计字段以对该列求和,那么结果将在页眉中为0,在页脚中为10,并且如果您将此运行总计字段放在明细部分中,它将显示该行(1、2、3,...,9、10)之前的累计值.
  9. 您可以类似地考虑组页眉和页脚.

I've looked throughout multiple guides, but none seem to give good guidelines as to when to put items into Group Header vs Details vs Group Footer.

Generally, my understanding is to put totals of any kind into the appropriate level group footer, as the header runs first -> details -> footer.

I'm really confused, as I had to set up a more complex report recently. I've got three tables - a "job master", "billings master (connected by job number)", and "costings master (connected by job number)". I set up a group for the "job master" job numbers, and tried to pull billings and costings from each of the other tables. However, no matter where I put the information (group header, details, or group footer) some of it comes out wrong.

We needed the report asap, so I ended up making one subreport for the billings, and another subreport for the costings, and used universal variables to pull things out of the subreport. This is not efficient and has a very long runtime, but the data is right. I put the subreports in the footer.

I'm sure there's probably a smarter way to do this, but it seems I don't really understand how to use header/footer/details sections when you have fields from multiple databases to pull from. Anyone have any pointers? Thanks!

解决方案

Your question is kind of too broad. If you report a specific case, i am sure you will get more help.

But what i can say for now, your probably already figured out by your self:

  1. Details section show iterative data.
  2. Header and footer shows non-iterative data (except, someway, group header and group footer).

If you play with "running total fields" in those sections and compare them with "summary fields", you will notice important stuff. I believe you are confused because you were expected the behavior of "running total fields" where you did use "summary fields", but i am just speculating.

I do not know how Crystal Reports is implemented, but here is my mental model that helps me to understand what is going on in the sections.

  1. Suppose you have a report with two tables and you have no subreports.
  2. First, Crystal will join your tables. The join will be accordingly to how you set the links between the tables. If you do not set up the links correctly, you will end up with a cartesian product of the tables, wich probably means undesired repeated rows.
  3. The result of this join is a "projection" with N rows. So, for each row, it will print a "details" section.
  4. So, if you put one field (a column actually) of the table in the details section, you will see the values beeing printed like you probably expect.
  5. But if you put the same field in the page header, it will print the first occurrence.
  6. But if you put the same field in the page footer, it will print the last occurrence (not sure if it is the last).
  7. Summary fields will be computed after the iteration over the rows. It means that it does not matter if they are on the header or in the footer - the result is the same. So, if there are 10 rows for the details section where a column has the value 1 for all the rows, and you create a summary field to sum up this column, its result will be 10 in both sections (header and footer).
  8. Running total fields will be computed on the fly. So, if there are 10 rows for the details section where a column has the value 1 for all the rows, and you create a running total field to sum up this column, the result will be 0 in the header, 10 in the footer, and if you put this running total field in the details section, it will show the accumulated value up to that row (1, 2, 3, ..., 9, 10).
  9. You can think analogously for groups headers and footers.

这篇关于Crystal Reports公式及其在不同部分中的运行方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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