2020年7月30日 星期四

QuickReport 群組頁數/群組合計頁數

    ..
    labPageCount: TQRLabel;
    labTotalCount: TQRLabel;
    ..
  private
    { Private declarations }
    F_GroupPageCount:TStringList;
    F_GroupTotalCount:TStringList;
    ..
  end

procedure FormCreate(Sender: TObject);
begin
  F_GroupPageCount := TStringList.Create;
  F_GroupTotalCount := TStringList.Create;
end;


procedure labPageCountPrint(sender: TObject;  var Value: WideString);
var sGroupStr:String;
  iCount:Integer;
begin
  //群組頁數
  if QuickRep1.Printer.ShowingPreview or QuickRep1.QRPrinter.aPrinterSettings.Printer.Printing then
  begin
    sGroupStr := QuickRep1.DataSet.FieldByName('xxx').AsString;
    iCount := StrToIntDef(F_GroupPageCount.Values[sGroupStr], 0);
    F_GroupPageCount.Values[sGroupStr] := IntToStr(iCount + 1);
    Value := F_GroupPageCount.Values[sGroupStr];
  end;
end;


procedure labTotalCountPrint(sender: TObject;  var Value: WideString);
var sGroupStr:String;
  iCount:Integer;
begin
  //群組合計頁數 
  sGroupStr := QuickRep1.DataSet.FieldByName('xxx').AsString;
  if (not QuickRep1.Printer.ShowingPreview) and 
    (not QuickRep1.QRPrinter.aPrinterSettings.Printer.Printing) then
  begin
    iCount := StrToIntDef(F_GroupTotalCount.Values[sGroupStr], 0);
    F_GroupTotalCount.Values[sGroupStr] := IntToStr(iCount + 1);
  end
  Value := F_GroupTotalCount.Values[sGroupStr];
end;


procedure QuickRep1BeforePrint(Sender: TCustomQuickRep; var PrintReport: Boolean);
begin
  F_GroupPageCount.CommaText := '';
end;



QuickRep1.Prepare;
QuickRep1.PreviewModule;

沒有留言:

張貼留言