Recent

Author Topic: Help with sum Lazreport  (Read 2647 times)

elidorio

  • Sr. Member
  • ****
  • Posts: 295
Help with sum Lazreport
« on: February 28, 2016, 05:55:54 pm »
Good afternoon,
Helps to make a sum in LazReport.
I want to add only the values that are in yellow, he this summing the entire column,
The sum is: 5.902,00 + 1.650,00 + 7.516,00) = 15.068,00
which this wrong?
« Last Edit: February 28, 2016, 06:21:56 pm by elidorio »
Lazarus 1.4.4 | FPC 2.6.4 | Windows / Linux Debian

balazsszekely

  • Guest
Re: Help with sum Lazreport
« Reply #1 on: February 28, 2016, 06:16:41 pm »
I cannot extract the .7z file, however you can put a footer band to your report, then:
Code: Pascal  [Select][+][-]
  1. var
  2.   SumAll, SumPart1, SumPart2, SumPart3: Double;
  3.  
  4. procedure TForm1.frReport1BeginBand(Band: TfrBand);
  5. begin
  6.   if Band.Typ = btDetailData then //or something else
  7.   begin
  8.     SumPart1 := qWhatever.FieldByName('SUMPART1').AsFloat; //this is just an exemple
  9.     SumPart2 := qWhatever.FieldByName('SUMPART2').AsFloat;
  10.     SumPart3 := qWhatever.FieldByName('SUMPART3').AsFloat;
  11.   end;
  12.   //all other bands are printed at this stage, so SumPart1, SumPart2, SumPart3 is known
  13.   if Band.Typ = btPageFooter then
  14.   begin
  15.     SumAll := SumPart1 + SumPart2 + SumPart3;
  16.   end;
  17.  
  18. end;
  19.  
  20. procedure TForm1.frReport1EnterRect(Memo: TStringList; View: TfrView);
  21. begin
  22.   if (View is TfrMemoView) then
  23.   begin
  24.     (View as TfrMemoView).FillColor := clYellow;
  25.  
  26.     if (View as TfrMemoView).Name = 'mSumAll' then
  27.     begin
  28.       (View as TfrMemoView).Memo.Clear;
  29.       (View as TfrMemoView).Memo.Add(SumAll);
  30.        Exit;
  31.     end;
  32.  
  33.     if (View as TfrMemoView).Name = 'mSumPart1' then
  34.     begin
  35.       (View as TfrMemoView).Memo.Clear;
  36.       (View as TfrMemoView).Memo.Add(mSumPart1);
  37.        Exit;
  38.     end;
  39.     //...
  40.   end;
  41. end;                
  42.  

« Last Edit: February 28, 2016, 06:22:35 pm by GetMem »

elidorio

  • Sr. Member
  • ****
  • Posts: 295
Re: Help with sum Lazreport
« Reply #2 on: February 28, 2016, 06:23:29 pm »
Updated to Zip. It is the .lrf file that can not do uplood.
Lazarus 1.4.4 | FPC 2.6.4 | Windows / Linux Debian

balazsszekely

  • Guest
Re: Help with sum Lazreport
« Reply #3 on: February 28, 2016, 09:33:39 pm »
@elidorio
Ok, I was able to open the lrf file. Please check my previous post, the same applies with a little modification.

 

TinyPortal © 2005-2018