在网上找了以下代码,不过不太明白
unit Report;
var
lPageIndex: Integer;
lList: TStringList;
MyPageNo,MyPageTotal:integer;
procedure Self_OnScriptbegin
Report(Sender: TObject);
begin
if not Self.FinalPass then
begin
lList := TStringList.Create;
lList.Add('0');
end;
end;
procedure Self_OnScriptEndReport(Sender: TObject);
begin
if Self.FinalPass then
begin
lList.Free;
lList := nil;
end;
end;
procedure columnFooter1_OnBeforePrint(Sender: TObject);
begin
lPageIndex := lPageIndex + 1;
// MyPageNo := 0;
//hzqinmb:MyPageNo须在var下声明吗?这是重置后的页码吧?我也试过把它加在var下。
if not Self.FinalPass then
lList.Add('0');
end;
procedure Page1_Onbegin
Page(aPageNo: Integer);
begin
if Self.FinalPass then
begin
MyPageTotal := lList[lPageIndex];
//hzqinmb:MyPageTotal须在var下声明吗?这是重置后的总页数吧?我也试过把它加在var下。
end
else
begin
lList[lPageIndex] := IntToStr(StrToInt(lList[lPageIndex]) + 1);
end;
MyPageNo := MyPageNo + 1;
end;
procedure Page1_OnActivate(Sender: TObject);
var
i: Integer;
begin
lPageIndex := 0;
MyPageNo := 0;
MyPageTotal:=0;
end;
procedure ColumnFooter1_OnAfterPrint(Sender: TObject);
begin
if MyPageNo=MyPageTotal then
MyPageNo:=0;
end;
procedure Main;
begin
MasterData1.spHeight:=0;
//将主项数据高度设为0,从而使其只控制数据而不显示
Self.OnScriptbegin
Report := Self_OnScriptbegin
Report;
Self.OnScriptEndReport := Self_OnScriptEndReport;
Page1.OnActivate := Page1_OnActivate;
Page1.Onbegin
Page := Page1_Onbegin
Page;
columnFooter1.OnBeforePrint := columnFooter1_OnBeforePrint;
//hzqinmb:groupFooter1是页脚吗?假设已放入一个Memo在页脚上,请问如何才能把重置后的页码和总页数打印在memo上?memo.Asstring:='第'+IntToStr(myPageNo)+'页 共'+IntToStr(myPageTotal)+'页'?
end;
end.