| 元件 | 用途 |
|---|---|
| TQuickRep | 報表容器,擁有座標系統,Bands 屬性自動加入頻帶 |
| TQRLabel | 靜態文字(如標題),Caption 直接列印 |
| TQRDBText | 資料庫欄位值,DataSet/DataField 綁定 |
| TQRSysData | 系統資訊:頁碼、日期、時間、報表標題 |
| TQRMemo | 多行靜態文字 |
| TQRRichText | Rich Text 格式,可連結 Form 上的 TRichEdit(需 32 位元版) |
| TQRShape | 方框、圓形、直線 |
| TQRImage | 靜態圖片(BMP/WMF/ICO) |
| TQRDBImage | 資料庫圖片欄位 |
| TQRBand | 定位報表區塊(標題、明細、頁尾等),上可放置其他元件 |
| TQRGroups | 多層群組操作,依 Expression 值變化自動換群 |
| TQRExpr | 運算式元件,支援條件邏輯、彙總函式(Count、Sum 等) |
透過 TQRBand.BandType 設定類型,或展開 TQuickRep.Bands 自動建立。
TTable:DatabaseName=BCDEMOS, TableName=Customer, Active=trueTQuickRep:DataSet=Table1Bands,設 HasDetail=true(自動建立 Detail Band)TQRDBText:DataSet=Table1, DataField=CompanyTQuickRep → Preview 預覽QuickRep1->Preview(); 或 QuickRep1->Print();TQuery:SQL: SELECT * FROM Customer ORDER BY State, Company, Active=trueTQuickRep:DataSet=Query1TQRGroups → 自動建立 Group Header BandTQRBand,設 BandType=rbGroupFooter,連結 TQRGroups.FooterBandTQRGroups.Expression = Query1.State(State 值變化即換群)TQRExpr:Expression: if(State<>'', State, 'Unknown state')TQRDBText:Company, Contact, PhoneTQRExpr:Expression: 'Customers in '+State+': '+Str(Count)在 TQuickRep.OnFilter 事件撰寫邏輯:
procedure TForm1.QuickReport1Filter(var PrintRecord: Boolean);
begin
PrintRecord := False; // 預設不列印
if YourTable.FieldByName('WantedField').AsInteger <= 100 then Exit;
if YourTable.FieldByName('WantedField').AsInteger >= 150 then Exit;
PrintRecord := True; // 100 < 值 < 150 才列印
end;
PrintRecord 為 var 參數,設為 True 列印該筆,False 略過。