简体   繁体   English

FastReport - 如何将特定的groupfooter值与新的页脚区域相加

[英]FastReport - How to sum specific groupfooter values to a new footer band

i'm trying to do the following with fastreport and delphi. 我正在尝试使用fastreport和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 . GroupHeader ------->客户销售员MasterData的关键-------> CustomerName,Balance GroupFooter -------> Salesman-1 MasterData的总和(余额)------- > CustomerName,Balance GroupFooter -------> Salesman-2 MasterData的总和(余额)-------> CustomerName,Balance GroupFooter -------> Salesman-3的总和(余额) 。 . . MasterData -------> CustomerName, Balance GroupFooter -------> Sum(Balance) of Salesman-N MasterData -------> CustomerName,Balance GroupFooter -------> Salesman-N的Sum(Balance)

====> Here want to have : Footer-2 -------> SUM( Sum(Balance) of Salesman-1, Sum(Balance) of Salesman-2, Sum(Balance) of Salesman-3 ) (ONLY !!!) ====>这里想要:Footer-2 -------> SUM(Salesman-1的总和(余额),Salesman-2的总和(余额),Salesman-3的总和(余额)) (只要 !!!)

ReportFooter --------> Total Customer Balance. ReportFooter -------->总客户余额。

Has anyone an idea to solve the problem with fastreport script engine? 有没有人有想法用fastreport脚本引擎解决问题?

Thank you. 谢谢。

I would create a report global variable 'salessum' 我会创建一个报告全局变量'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. 在细节带的OnBeforePrint事件中,如果sapleum是所需的销售人员之一,则增加salessum。

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. 如果您希望在报告末尾添加额外的总和,则添加报告摘要带,并在OnBeforePrint事件中将相应文本字段的值设置为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. 或者,如果您希望在销售人员3小计之后立即添加额外的金额,然后在销售人员组页脚带中添加文本字段,并在OnBeforePrint事件中将其visible属性设置为true / false,具体取决于您当前正在处理的销售人员密钥并设置其值得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!). 希望这是有道理的(并且是你实际想要实现的目标!)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM