根据表中的编号判断,当编号是“****“时将其内容赋给表头组件,遇到下一四个星号之间的内容在detailband中打印,并再遇到下四个星号时换页。
例数据格式形如:
bh     mc   dw .......
****   ddd  m2 .......//要求在pageHeaderband中打印
0001   d001 m2 .......//在detailband中打印
。。
****   ddd  m2 .......//要求在pageHeaderband中打印,这时应换页
0001   d001 m2 .......//在detailband中打印
。。

解决方案 »

  1.   

    报表的强制分页输出    
        
    先声明一个变量varTempName : string;调用报表预览procedure TForm1.Button1Click(Sender: TObject);beginquery1.Close;query1.Open;TempName := query1.fieldbyname('name').AsString;QuickRep1.Preview;end;调用DetailBand的BeforePrint方法procedure TForm1.DetailBand1BeforePrint(Sender: TQRCustomBand;var PrintBand: Boolean);beginif Query1.FieldByName('Name').AsString <>TempName thenbeginquickrep1.NewColumn;tempname := query1.fieldbyname('name').Asstring;end;end;
     
     
      

  2.   

    如何控制编号前四位为"****"的行不打印出来,在needData是不是只要Next就会打印呢?
    MoreData:=true;
    with datamodule1.Query3 do
     begin  //next;
    if(copy(trim(fieldbyname('bh').AsString),1,4)='****') then
      begin
      //nbPrint:=false;
       if nRowH=0 then
       begin               showmessage('cc');
       QRLabel13.Caption:=trim(copy(trim(fieldbyname('bh').AsString),5,16));
       next;
       bPrint:=true;
       nbPrint:=false;
       end
       else
       begin    showmessage(inttostr(nRowH)); //如不满一页时补充空格
       for j:=1 to strcols do
         begin
           TQRRichText( self.FindComponent('QRRichText'+inttostr(j+24))).Lines.clear;
           QRRichText48.Lines.Clear;
           DetailBand1.Height:=22+IncRowHeight;
           QRShape53.Height:=22+IncRowHeight;
           QRShape51.Top:=DetailBand1.Height-2;
           TQRShape(self.FindComponent('QRShape'+inttostr(25+j))).Height:=22+IncRowHeight;
         end;
       bPrint:=false;
       nbPrint:=true;
       end;
    end;
    DetailBand1.Height:=DefaultDetailHeight;
     QRShape51.Top:=DetailBand1.Height-2;
     QRShape53.Height:=DetailBand1.Height;
    if not eof then
    begin
     if bPrint then   //   if bPrint then
    begin     //showmessage(inttostr(nrowh));
    //nbPrint:=true;
    PrintRowData()
    end;
    end;
    nRowH:=nRowH+DetailBand1.Height;
     if eof then
        begin
          if isfull then
             begin
               for j:=1 to strcols do
                 begin
                  TQRRichText(self.FindComponent('QRRichText'+inttostr(j+24))).Lines.clear;
                  QRRichText48.Lines.Clear;
                  DetailBand1.Height:=22+IncRowHeight;
                  QRShape53.Height:=22+IncRowHeight;
                  QRShape51.Top:=DetailBand1.Height-2;
                  TQRShape(self.FindComponent('QRShape'+inttostr(25+j))).Height:=22+IncRowHeight;
                 end;
               if nRowH>=PrintHeight then
                 MoreData:=false;
             end
             else
              MoreData:=false;
        end;
    if bPrint then
     Next;
    end;