FastReport - 如何将特定的组页脚值求和到新的页脚区域

发布于 2024-09-18 07:23:28 字数 553 浏览 5 评论 0原文

我正在尝试使用 fastreport 和 delphi 执行以下操作。我有一份报告,其中包含...

GroupHeader -------->客户推销员的关键 主数据------>客户姓名、余额 组页脚 --------> Salesman-1 的总和(余额) 主数据------>客户姓名、余额 组页脚 --------> Salesman-2 的总和(余额) 主数据------>客户姓名、余额 组页脚 --------> Salesman-3 的总和(余额) 。 。 。 主数据------>客户姓名、余额 组页脚 -------->推销员-N 的总和(余额)

====>这里想要有: 页脚-2 --------> SUM( 销售员 1 的总和(余额)、销售员 2 的总和(余额)、销售员 3 的总和(余额) ) (仅!!!)

ReportFooter -------->客户总余额。

有谁有解决 fastreport 脚本引擎问题的想法吗?

谢谢。

i'm trying to do the following with fastreport and delphi. I have a report containing...

GroupHeader -------> Key to Customer Salesman
MasterData -------> CustomerName, Balance
GroupFooter -------> Sum(Balance) of Salesman-1
MasterData -------> CustomerName, Balance
GroupFooter -------> Sum(Balance) of Salesman-2
MasterData -------> CustomerName, Balance
GroupFooter -------> Sum(Balance) of Salesman-3
.
.
.
MasterData -------> CustomerName, Balance
GroupFooter -------> Sum(Balance) of Salesman-N

====> Here want to have :
Footer-2 -------> SUM( Sum(Balance) of Salesman-1, Sum(Balance) of Salesman-2, Sum(Balance) of Salesman-3 ) (ONLY !!!)

ReportFooter --------> Total Customer Balance.

Has anyone an idea to solve the problem with fastreport script engine?

Thank you.

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

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

发布评论

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

评论(1

甜扑 2024-09-25 07:23:28

我将创建一个报告全局变量“salessum”,

var
  salessum: extended;

procedure MYReportOnStartReport(Sender: TfrxComponent);
begin
  salessum := 0.0;
end;

如果它是所需的推销员之一,则在详细信息区域的 OnBeforePrint 事件中增加 salessum。

procedure MYReportDetailBeforePrint(Sender: TfrxComponent);
begin
  if (mydata.salesmankey = "key 1") or (mydata.salesmankey = "key2") or (...) then
  begin
    salessum := salessum + mydata.amount;
  end;
end;

如果您希望在报告末尾添加额外的总和,请添加报告摘要区域,并在 OnBeforePrint 事件中将相应文本字段的值设置为 salessum 的格式化字符串。

procedure MYReportSummaryBeforePrint(Sender: TfrxComponent);
begin
  txtMyBestSalesMenTotal.Text := FormatFloat('#,##0.00', salessum);
end;

或者,如果您希望在销售员 3 小计之后立即添加额外总和,则在销售员组页脚区域中添加一个文本字段,并在 OnBeforePrint 事件中将其可见属性设置为 true/false,具体取决于您当前正在处理的销售员键并设置其值与 salessum 的值之比。您还需要确保带子自动拉伸。

我已经开始使用脚本和报告变量进行几乎所有求和,因为它变得更容易控制何时何地应该递增或重置或打印等。使用内置求和函数(在任何报告系统中)是唯一有用的非常简单的总数——出于某种原因,我的报告中很少有这样的总数。

希望这是有道理的(这就是您真正想要实现的目标!)。

I would create a report global variable 'salessum'

var
  salessum: extended;

procedure MYReportOnStartReport(Sender: TfrxComponent);
begin
  salessum := 0.0;
end;

In the OnBeforePrint event of the detail band increment the salessum if it is one of the desired salesmen.

procedure MYReportDetailBeforePrint(Sender: TfrxComponent);
begin
  if (mydata.salesmankey = "key 1") or (mydata.salesmankey = "key2") or (...) then
  begin
    salessum := salessum + mydata.amount;
  end;
end;

If you want the extra sum at the end of the report then add a report summary band and in the OnBeforePrint event set the value of the appropriate text field to the formatted string of salessum.

procedure MYReportSummaryBeforePrint(Sender: TfrxComponent);
begin
  txtMyBestSalesMenTotal.Text := FormatFloat('#,##0.00', salessum);
end;

Alternatively, if you want the extra sum immediately after the salesman 3 subtotal then add a text field in the salesman group footer band and in the OnBeforePrint event set its visible property to true/false depending on which salesman key you are currently processing and set its value to the value of salessum. You will also need to make sure that the band stretches automatically.

I have started to do pretty much all summing using script and report variable as it becomes so much easier to control when and where they should be incremented or reset or printed etc. Using the built in sum functions (in any reporting system) is only useful for very straightforward totals - which, for some reason, very few of my reports are.

Hope that makes sense (and is what you're actually trying to achieve!).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文