我想把StringGrid数据分页打印,每页打印 22 行.
现在好像每页都会打印出22个标题,都是一行标题,一行数据.
一页也全部打满了.
以下是我的源程序,请大家帮我看看,问题是出在什么地方.
unit Unit2;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, QuickRpt, QRCtrls;type
  TForm2 = class(TForm)
    QuickRep1: TQuickRep;
    DetailBand1: TQRBand;
    QRBand1: TQRBand;
    QRLabel1: TQRLabel;
    procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    procedure QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form2 :TForm2;
  QRLabel: array of array of TQRLabel;
  QRShape: array of array of TQRShape;
  CurrRow,pageRow: integer; //当前行,总行数,每页的行数
  GridColumn,GridCountRow:integer ;//stringGrid中的行,列
  inPage: integer;implementationuses UMain;{$R *.dfm}procedure TForm2.QuickRep1BeforePrint(Sender: TCustomQuickRep;
  var PrintReport: Boolean);
var
i,j: integer;
begin
  CurrRow := 1;
  SetLength(QRLabel,pageRow+1,GridColumn);  // 而此处应该是生成每页打印的行数,另加一个标题行
  SetLength(QRShape,pageRow+1,GridColumn);
  //动态创建每面的行数及Qrlabel
  for j:=0 to pageRow do
  begin
    for i:=0 to GridColumn - 1 do
      begin
        QRShape[j,i]:=TQRShape.Create(self);
        with QRShape[j,i] do
          begin
            Parent:=DetailBand1;
           Left:=i*92;            Top:=j*24;
            Height:=25;
            Width:=93;
            Width := FrmMain.StringGrid1.ColWidths[i];
            Enabled:=True;
            Visible:=True;
          end;
        QRLabel[j,i]:=TQRLabel.Create(self);
        with QRLabel[j,i] do
          begin
            Parent:=DetailBand1;
            Left:=i*92+2;
            Top:=j*24+6;
            Height:=16;
            Width:=90;
            Alignment:=TaCenter;
            AutoSize:=True;
            Caption:='';
            Enabled:=True;
            Visible:=True;
          end;
        end;
      end;  //初始化第一栏标题
  for i := 0  to GridColumn -1  do
     QRLabel[0,i].Caption := FrmMain.StringGrid1.Cells[i,0];
end;
/******************估计出问题的就在QuickRep1NeedData这个过程*********************************//
procedure TForm2.QuickRep1NeedData(Sender: TObject; var MoreData: Boolean);
  var
  i,j: Integer;
begin
 if CurrRow > GridCountRow then  // 为要打印的StringGrid行数
 begin
    MoreData:=False ;
    exit;
 end
  else
  begin
   MoreData:=True;                                 //连续打印
  for j:=1 to pageRow do
    begin
      for i:=0 to GridColumn - 1 do
      begin
      if CurrRow > GridCountRow then
          QRLabel[j,i].Caption := ''
        else
         QRLabel[j,i].Caption:=FrmMain.StringGrid1.Cells[i,CurrRow]; // 打印当前行对应的数据
      end;
    end;
    Inc(CurrRow);
  end;
end;procedure TForm2.FormCreate(Sender: TObject);
begin
  pageRow := 20;  //每页打印20行
  GridColumn := FrmMain.StringGrid1.ColCount;    //StringGrid总列数
  GridCountRow := FrmMain.StringGrid1.RowCount;  //StringGrid 总行数
end;
end.
请大家帮我改正 
 
问题进行扩展,如果我要在StringGrid 中实现分组功能(而且要打印),有什么好办法。因为我的数据是从文件中读取的,所以本人想在StringGrid的基础上增加一些功能.