2010-09-01 87 views

回答

1

首先準備文檔,因此係統本身知道將生成多少頁面。你可以使用一個系統變量(手邊沒有QR來告訴你確切的名字)。

例如:

procedure TForm1.Click(Sender: TObject); 
begin 
    //this actually run the report in memory to 
    //calculate things like total page count 
    Report1.Prepare; 
    Report1.Print; //or PreviewModal; 
end; 
0

解決方案是在預覽過程中統計頁數,因此當您將其發送到打印機時,您可以將其放置在頁腳中。

6
procedure TForm1.Button1Click(Sender: TObject); 
begin 
    Form2.QuickRep1.Prepare; 
    Form2.QuickRep1.FTotalPages := Form2.QuickRep1.QRPRinter.PageCount; 
    Form2.QuickRep1.QRPrinter.Free; 
    Form2.QuickRep1.QuickRep1.QRPrinter := nil; 
    Form2.QuickRep1.PreviewModal; // or .Print 
end; 

FTotalPages在窗體2保持所述TQuickRep部件聲明。

public 
    { Public declarations } 
    FTotalPages: Integer; 

注意,QRPrinter對象必須經過釋放準備和PreviewModal(或.PRINT)事情之前,你會得到一個內存泄漏。

在窗體2,在Quickreport1,放置QRLabel,並實現它的onPrint事件處理

procedure TForm2.QRLabel1Print(sender: TObject; var Value: string); 
begin 
    Value := 'Page: ' + IntToStr(QuickRep1.QRPrinter.PageNumber) + ' of ' + IntToStr(FTotalPages); 
end;