                 12 

       Quick Reports 

    Quick Reports     Delphi  ,   
  VCL. 

      

              Quick 
Reports,   ,      . 

       

      

    Quick Reports     ,    
 . 32-  Quick Reports     
 Delphi 2.0.   ,   Delphi 3, 
 .        Quick 
Reports,   ,      . 
       Delphi 3   QRDemo ( Delphi 
3\Demos\QuickRpt)      Quick Reports. 
      Quick Reports  ,     . 
    1.   TQuickRep  . 
    2.  ,   . 
    3.      Quick Reports  
      . 
     Quick Reports  1  Delphi 2.0   Quick Reports 
 2     Delphi 3.     , 
   Delphi 2.0,    
,        Quick Reports. 
      Quick Reports 
      Quick Reports      
 Delphi,       
. - w 

    294 

      VCL   Quick Reports   
  ,         
 ,     OLE  DDE   
    . 
     18   ,    
QReport  .         
    .      
        . 

     TQuickRep 

     TQuickRep      Quick Reports,   
    ,   .  
 TQuickRep   ,     
 ,       . 

     Bands 

       Bands       
    . Bands   -  
  : HasColumnHeader, HasDetail, HasPageFooter, 
HasPageHeader, HasSummary  HasTitle.       
. 12.1. 

     12.1.   Band 

              

    rbChild	  (Child band)  ,     
   ,     
    rbColumnHeader	  (Column Header band)   
       
    rbDetail	  (Detail band)      
    rbGroupFooter	  (Group Footer band)    
  (master/detail report    "/") 
    rbGroupHeader	  (Group Header band)    
  (master/detail report) 
    rbOverlay	  (Overlay band)     
       
    rbPageFooter	  (Page Footer band)   
   
    rbPageHeader	  (Page Header band)   
  
    rbSubDetail	  (Sub Detail band)    
    "/" 
    rbSummary	  (Summary band)       
    rbTitle	  (Title band)       

            ,  
 .      ,    
   . 

     DataSet 

     DataSet ,        
 .       TTable  TQuery. 
         ,   
    "/",    DataSet 
 TQuickRep     .     
,    :   Quick Reports,    
   . 

     Options 

     Options     : FirstPageHeader, 
LastPageFooter, TwoPassReport, MultiThreaded  Compression.   
FirstPageHeader  LastPageFooter ,      
        . 
  

     12.                                 295 

    Multi-Threaded   ,      ,  
     ,  ,   
  .    TwoPassReport,   
TQRExpr      ,   
      . ,    
           
    ,      
,      .   
    ,      
  ,        
,   .    Compression  
   .         
 ,   , ..  ""  
    . 

     Page 

       Page     , 
,    ..       
    . 

     PrinterSettings 

       PrinterSettings     
  , ,      , 
   (    ),   
  . 

     ReportTitle 

     ReportTitle   TQRSysData   
    . 

     ShowProgress 

     ShowProgress     , 
        . 
       Cancel. 

     OnNeedData 

     OnNeedData       ,  
  BDE.      ,  Quick 
Reports     "".       
  BDE,       TQRLabel  
.  OnNeedData    MoreData,   
  False,   . 

     TQRSubDetail 

     TQRSubDetail       
  "/" (master/detail).    
   Bands, DataSet  Master. 

     Bands 

     -   HasFooter  HasHeader.  
        
 . 

     DataSet 

     DataSet ,      
       .  
   ,       
  "/". 

     Master 

     Master    ,     
.     TQuickRep     TQRSubDetail. 

     TQRBand 

     TQuickRep  TQRBand, ,     
 Quick Reports.     TQRBand    
.         Bands  
TQuickReport,      TQRBand.   
 ,     ,      . 

    296                                      III.     


     BandType 

     BandType      , 
   TQRBand.   ,    
    .  . 12.1   
     . 

     ForceNewCoIumn 

        ,      
   . 

     ForceNewPage 

         ,     
    .      
 True          
 .   "/"     
  ,      
             . 

     LinkBand 

      ,       
 ,  ,        
.  LinkBand ,   Quick Reports 
       ,    . 
           
,     .   
  ( 1      2,   
  3,  ..). 

     

        .  ,   1 
   2,  )   1   2. 
   2   1    ,  
 1    ,   2  . 

     BeforePrint 

     BeforePrint      . 
  PrintBand       
,    .  PrintBand  True  
      False    . 
       "/",   
    ,     
  . 

      1 

    ,       BeforePrint  
,    0 Ю^ ,     
       Preview   . 
 BeforePrint      ,    
Preview  ,     ,    
   ,  , ,    
        . 

     TQRChildBand 

     TQRChildBand    ,   
  .          
,     "/".   
     TQRChildBand      
1   True. 
        ,    
Memo-   ,     . 
   AutoStrech  QRDBText  True,  
,    .     
,   Memo-   ,   
    ,     . 
   Memo-   ^,  
 .         ~ 

     ParentBand 

     ParentBand        
 .         
   (    ). 

     12.                                 297 


     TQRGroup 

     TQRGroup      . 
      "/",  
       . 

     Expression 

         ,   
,     . ,  
     ,   , 
          
  Expression: 

    copy(fieldname,1,1) 


     Master 

        ,   TQRGroup  
 .      TQuickRep,    . 

     TQRLabel 

     TQRLabel        Quick 
Reports 2.0,        
,  ,       TLabel  
     .     
" ",     ,      
;           . 

     TQRDBText 

     TQRDBText     ,  
     ,  ,  
  Memo-.         , 
     ,    DataSet 
 DataField . 

     AutoStretch 

    AutoStretch   ,  ,   
""   TQRDBText     
Memo-.    TQRDBText   Memo   
 AutoStretch  False,   ( Memo-)  
     TQRDBText.     
 True,      Memo-,   
      . 

     

     AutoStretch     TQRDBText  
 (      Quick Reports).  
  Memo-,       
    ,   Memo-   
,       . 

     TQRExpr 

     TQRExpr        
    .       
 Quick Reports    ,    
.  Expression      .   
     Expression,      
(...),      Expression builder (. 
12.1).      , 
  . 

     ResetAfterPrint 

      ,  ,     
TQRExpr     ,   .  
   "/",      TQRExpr 
    ,     
   . 

    298                                      III.     


     TQRSysData 

     TQRSysData        
      . 

    . 12.1.   

     Data 

     Data   ,    
TQRSysData.  . 12.2      , 
      .    
     ,     . 

     12.2.   Data 

    	 

    qrsDate	  
    qrsDateTime	    
    qrsDetail Count	    
    qrsDetaiINo	  
    qrsPageNumber	  
    qrsReportTitle	  ReportTitle  TQuickRep 
    qrsTime	  

     TQRMemo 

     TQRMemo     Memo-,  
--.      ,    
TMemo,          Lines. He 
 Memo- ,   ,   
^^.^^   

    TQRDBText. 

     12.                                 299 

     TQRRichText 

     TQRRichText     RTF- (Rich Text 
Format      Microsoft).  
TQRRichEdit   ParentRichEdit,    
 TQRRichEdit    TRichEdit.    
TQRRichEdit   Memo-RTF-  . 

     TQ^DBRichText 

     TQRDBRichText    TQRRichEdit  . 

     TQRShape 

     TQRShape       . 
   Shape.  . 12.3    Shape. 

    	 

    qrsCircle	 
    qrsHorline	  
    qrsRectangle	 
    qrsRightAndLeft	     
    qrsTopAndBotton	     
    qrsVertLine	  


     TQRImage 

     TQRImage     
  .        
    . 

     TQRDBImage 

     TQRDBImage       ,  
       .    
,      TDBImage. 

     TQRCompositeReport 

     TQRCompositeReport    
 .        ,   
   ,      
   .       
 ,    ,     
 .     TQRCompositeReport  
 OnAddReports.   OnAddReports     
Reports,   . 

    Procedure TForml.QRCompositeReportlAddReports(Sender: Tobject); 
    begin 
    with Sender as TQRCompositeReport do begin 
    // QuickReport2, QuickReport3  QuickReport4   TQuickRep. 
    Reports.Add(QuickReport2) ; 
    Reports.Add(QuickReport3) ; 
    Reports.Add(QuickReport4); 
    end; 
    end; 


    300                                      III.     


     TQRPreview 

     TQRPreview       
     Quick Reports.  
   Custom Preview    " 
 "  . 

     TQRChart 

     TQRChart     TChart  
,     .    
   TQRGroup,       
    .~"-" ~L"'"""""'

      

    Delphi        Quick Report 
Wizard ( )  Report Templates ( ).    
,      . 

     Quick Report 

    Quick Report Wizard    Business  .   
        .  . 12.2 
  Business   New Item,  Quick Report. 

    . 12.2.  Business       
        DBDemos. 

    1.    Delphi. 
    2.   File^New    Delphi,    
 . 
    3.   Business,    QuickReport Wizard  
  . 
    4.   DBDemos   VENDORS. DB,     
 Next. 
    5.          ,    
 Next. 
    6.     UD3 QuickReport Wizard Example  
   Finish.     IDE Delphi. 
    7.   Table     Quick Reports  
    Active   Object Inspector  True. 
    8.      Quick Reports    
Preview   .    ,    
. 12.3. 

     12.                                 301 

           ,   
.  __       DataSet 
 TQuickRep     DataModule   .  
 ,       Expression   
TQRExpr,    ,         
 . 
    
    . 12.3.   ,    


      

      ,     Object Repository.  
 Forms    Quick Reports.  . 12.4  
  New Item      Forms.  
     ,    
,      .    
,       QuickReport 
Labels  QuickReport Master/Detail. 


    . 12.4.  Forms   


    302                                              III.     


       

       (List Template)      
,  ,       ( 
       
 ).          
   . 

       

       Labels      (labels). 
    ,     , 
     '^"6 " 
^          
 ,    Page  TQuickRep   
      . 
            
    DBDemos.     
 .  ,     , 
, ,           
.         ,   
 ,    "Attn:". 
    1.  ....^-..-_^ 
    2.   , TDataSource, TDBGrid    
TButton  . 
    3.   DatabaseName  TTable  DBDemos, 
 TableName   CUSTOMER.DB,   Active True. 
    4.   DataSet  TDataSource  Tablel,  
 DataSource  TDBGridDataSourcel,     . 
    5.   Caption   TButton  Preview, 
   TButton Print. 
    6.   File^New    Delphi.    
  New Item.   Forms,    QuickReports Labels. 
    7.   Quick Reports   MasterTable  
 DBDemos,  TableName   CUSTOMER. DB,   Active  True. 
    8.    TQRDBText   . 
    9.   DataSet      TQRDBText 
 MasterTable.  DataField  ,   Company  
  , Contact   , Addr2   , a City, State  Zip 
   . 
    10.           
 BeforePrint  : 

    PrintBand := MasterTable['Country'] = 'US',

    11.         
    TQRDBText,     Contact: 

    if Value  '' then 
    Value := 'Attn: ' + Value; 

    12.      City.   ,  
    OnPrint  TQRDBText,     City: 

    Value := Value +', '; 

    13.   OnClick   Preview  : 

    QRListForm.Report.Preview; 

    14.   OnClick   Print  : 

    QRListForm.Report.Print; 

    15.  Unit2   USES Unitl. 

      12.1      Quick Reports.   
       Preview,   , 
  . 12.5.       
   UDELPHI3\CHP12\LABELPRT. 

     12.                                 303 


     12.1. \UDELPHi3\CHPl2\LABELPRT.      

    {  Labels QuickReport. } 
    unit Unit2; 
    interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
Qrctrls, quickrpt, DB, DBTables, ExtCtrls; 
    type 
    TQRListForm = class(TForm) 
    Report: TQuickRep; 
    MasterTable: TTable; 
    DetailBandl: TQRBand 
    QRDBTextl  TQRDBText 
    QRDBText2  TQRDBText 
    QRDBTextS  TQRDBText 
    QRDBText4  TQRDBText 
    QRDBTextS  TQRDBText 
    QRDBText6  TQRDBText 
    QRDBText?  TQRDBText 
    procedure QRDBText3Print(sender: TObject; var Value: String); 
    procedure DetailBandlBeforePrint (Sender: TQRCustoinBand; 
    var PrintBand: Boolean) ; 
    procedure QRDBText6Print(sender: TObject; var Value: Stringsprivate 
    { Private declarations } public 
    ( Public declarations } end; 
    var QRListForm : TQRListForm; 
    implementation ($R * .DFM} 
    procedure TQRListForm.QRDBText3Print(sender: TObject; var Value: Stringsbegin 
    Value := Value +',' ; 
    end; 
    procedure TQRListForm.DetailBandlBeforePrint 
    (Sender:  TQRCustomBand; var PrintBand: Boolean) ; 
    begin 
    //    . 
    PrintBand := MasterTable['Country'] = 'US'; 
    end; 
    procedure TQRListForm.QRDBText6Print(sender: TObject; 
    var Value: String); 
    begin 
    //    ,  'Attn:'  . 
    if Value  '' then 
    Value := 'Attn:  ' + Value; 
    end; 
    end. 


    304                                      III.     


    Kauai r)i'e Shoppe Kirk Enterprises Attn Erica Norman Attn Rudolph Clans 
4-976 Sugarloaf Hwy 42 Aqua Lane Suite 103  Kaual. HI 84766-1234 Houston, 
TX 77079	Blue Glass Happiness Atln Christine Taylor 6345 W. Shore LaneSanta 
Monica, CA 90410 
    Blue Jack Aqua Center George Bean & Co. Attn Ernest Barratt Attn Bill 
Wyere 23-738 Paddington Lane 73 Kins Salmon Way Suite 310 Walpahu, HI 9776 
Lugot. NC 29078	Divers of Venice Attn Sim one Green 220 Elm StreetVenice, FL 39224 
    Ocean Paradise Professional DrerE, Ltd. Attn Paul Gardner Attn ShIrteyM 
afters PO Box 8745 4734MelindaSt.	Larry^ Di\ing School Attn Isabelle Neece 
3562 NW Bruce Street 
    Kallua-Kona, HI 94756 Hoowr, AL 32145	Milveukle, OR 6277 
    The Depth Charge Dtvsrs olBlie-green Atln Sam Witherspoon Atln Nancy Bean 
15243 Undemeler Fy. 634 Complex A\e.	Vashon Ventures  Susan Smith 743 
Keyhole Court 
    Marathon. FL 35003 Pelham, AL 32145	Honolulu, HI 92856	'.
    Blue Sports OoM Coast Supply Attn Theresa Kunec Atln Elalne Falls 
20312lhA\e.Box746 223 Houston Place	Ocean Ad\entures Attn Paul Still POBox466Klhei	":.'& 
    eirihaldi. OR 91187 Mobile, AL 30696	Maul, HI 5736 
    Makai SCUBA Club San Pablo Dl\e Center Atln Donna Siaus Attn Patricia 

    . 12.5.  ,    Quick Reports 


     "/"  Quick Reports 

     "/"     Quick Reports 
  Column, Detail, Sub-Detail  Page Footer,    
   "/".       
   MasterTable  DetailTable  ,    
  . 
    ,     DBDemos Vendors  Parts.   
Vendors     ,    Parts  
        .  , 
       ,   
.     Vendors      
Parts,      .  ,    
    Vendors,      . 
    1.    Delphi. 
    2.   File^New    Delphi,    
 .   Forms,    QuickReports Master/Detail. 
    3.   File^New Data Module    Delphi,  
  .   Forms,    QuickReports Master/Detail. 
    4.           
TDataSource.    MasterTable,     
DetailTable.    TDataSource  MasterSource,    
 DetailSource.   DataSet  TDataSource  
   TTable.   DatabaseName 
 TTable  DBDemos.   TableName  
MasterTable  VENDORS,   Active True.  DetailTable 
  TableName  PARTS,  
MasterSourceMasterSource,  IndexName VenderNo,  MasterFields 
VenderNo,   Active  True. 
    5.     ( ),    
TDBGrid    TButton.    Unit3   USES. 
   TButton  Print.   
DataSource   TDBGrid  MasterSource,   
 DetailSource.      . 

     12.                                 305 

    6.   Quick Reports    ,   
   .   DataSet  
TQuickRep  MasterTable,   DataSet    
DetailTable.   ,   HasHeader   
Bands  . 
    7.        TQRLabel  
 VendorNo, Vendor  Status. 
    8.       TQRDBText  
 VendorNo, VendorName, Addressi, City, State, Zip   
 .   ForceNewPage  True,  
        .   
    ,     (False). 
    9.        TQRLabel  PartNo, 
Description  Cost. 
    10.       TQRDBText   
PartNo, Description  Cost. 
    11.    ,    ,  
     forePrint  : 
    PrintBand := DataModule3.DetailTable.RecordCount > 0; 
    12.   ,   "Preferred",   
"Standard".        True  False,   
 .   ,      
OnPrint  TQRDBText,    : 

    if Value = 'True' then 
    Value := 'Preferred'; 
    else 
    Value := 'Standard',

    13.      Cost     
     >1(1 OnPrint 
 TQRDBText,    Cost: 

    FmtStr(Value, '%m', [StrToFloat(Value)]); 

    14.   OnClick   Preview     : 

    QRListForm.Report.Preview; 

    15.   OnClick   Print     : 

    QRListForm.Report.Print; 

    16.  Unit2 ( Quick Reports)   USES  Uniti 
( ). 
      12.2      Quick Reports.   
       Preview,   , 
  . 12.6.       
   UDELPHI3\CHP12\MDRPT. 

     12.2. \UDELPHl3\CHPl2\MDPRT.    "/" 

    {  "/". } 
    unit Unit2; 
    interface 
    uses 
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Qrctrls, 
    quickrpt, DB, DBTables, ExtCtrls; 
    type 
    TQRListForm = class(TForm) 
    Report: TQuickRep; 
    DetailBandl: TQRBand; 
    PageFooterBandl: TQRBand; 
    TitleBandl: TQRBand; 
    ColumnHeaderBandl: TQRBand; 
    QRSysDatal: TQRSysData 


    306                                      III.     


    QRSysData2: TQRSysData 
    QRSubDetaill: TQRSubDetail 
    QRDBTextl  TQRDBText 
    QRDBText2  TQRDBText 
    QRDBText3  TQRDBText 
    QRDBText4  TQRDBText 
    QRDBText5  TQRDBText 
    QRDBText6  TQRDBText 
    QRDBText?  TQRDBText 
    QRDBTextS  TQRDBText 
    QRDBText9  TQRDBText 
    QRDBText10: TQRDBText; 
    QRDBTextll: TQRDBText; 
    QRLabell  TQRLabel; 
    QRLabel2  TQRLabel; 
    QRLabel3  TQRLabel; 
    GroupHeaderBandl: TQRBand; 
    QRLabel4  TQRLabel ; 
    QRLabelS  TQRLabel; 
    QRLabel6  TQRLabel; 
    procedure QRDBText3Print(sender: TObject; var Value: Strings
    procedure DetailBandlBeforePrint(Sender: TQRCustomBand; 
    var PrintBand: Boolean) ; 
    procedure QRDBText6Print(sender: TObject; var Value: Strings
    private 
    { Private declarations } 
    public 
    { Public declarations ) 
    end; 
    var 
    QRListForm : TQRListForm; 
    implementation 
    {$R * .DFM) 
    procedure TQRListForm.QRDBText3Print(sender: TObject; var Value: Strings
    begin 
    //   ,  "Preferred",   "Standard". 
    if Value = 'True' then 
    Value := 'Preferred' 
    else 
    Value := 'Standard'; 
    end; 
    procedure TQRListForm.DetailBandlBeforePrint(Sender: TQRCustomBand; var PrintBand: 
    Boolean) ; 
    begin 
    //  ,       . 
    PrintBand := DataModule3.DetailTable.RecordCount > 0; 
    end; 
    procedure TQRListForm.QRDBText6Print(sender: TObject; 
    var Value: String); 
    begin 
    FmtStr(Value, '%m', [StrToFloat(Value)]); 
    end; 
    end. 


     12.                                 307 


    . 12.6.   "/" 


       

          Delphi  
  TQRPreview.    
    . 
    1.        TQRPreview. 
    2.       ,    
   ,    . 
    3.       OnPreview   
,      : 
    PrevForm.QRPreviewl.QRPrinter := TQRPrinter(Sender); 
     PrevForm     , a 
QRPreviewl    TQRPreview. 
           
  .    Printer 
     Printer . 
       
      \UDELPHI3\CHP12\CUSTVIEW. 

     

     Quick Reports     .    
         
 ,  , "/"    
.  ,  Quick Reports    
   ,       
   .       
    ,    Delphi. 

    308                                      III.    