unit CodeReport; {$mode objfpc}{$H+} interface uses Classes , dB , DBGrids , FileUtil , PrintersDlgs , LR_PGrid , Forms , Controls , Graphics , Dialogs , RLReport , RLPreview, SysUtils, Datamodule,DelInv,Printers,RLTypes,TypInfo; procedure FortesReport(Grid: TDbGrid); implementation procedure FortesReport(Grid: TDbGrid); {Create and Preview a Report in code, of data in TBGrid using Fortes Report Initial code is to create a report with just a PageHeader band containing a Label} var i, CurrentLeft, CurrentTop : integer; cDebug : String; MyReport : TRLReport; // Report B_PageHead,b_ColHead,B_Detail,B_Footer : TRLBAND; // Report Bands (Only use B_PageHead) Lbl1,Lbl2,Lbl3 : TRLLabel; // Report Labels (Only Use Lbl1 ) begin MyReport := TRLReport.Create(Nil); // Create Report With MyReport do // Set Properties of Report Begin Name := 'MyReport'; AllowedBands := [btHeader]; PageSetup.Orientation := poLandscape; PageSetup.Papersize := fpA4; BackgroundMode := True; With Margins do Begin BottomMargin := 10; LeftMargin := 10; RightMargin := 10; TopMargin := 10; End; With Borders do Begin DrawTop := True; DrawRight := True; DrawBottom := True; DrawLeft := True; Style := bsSolid; Width := 2; End; With PreviewOptions Do Begin Defaults := pdIgnoreDefaults; FormStyle := fsNormal; ShowModal := True; WindowState := wsMaximized; End; End; CurrentLeft := 5; CurrentTop := 3; B_Pagehead := TRLBand.Create(MyReport); // Set Properties of Page Header With B_PageHead Do Begin Name := 'B_Pagehead'; BandType := btHeader; Height := 200; Width := MyReport.Width; color := clAqua; With Borders do Begin DrawTop := True; DrawRight := True; DrawBottom := True; DrawLeft := True; Style := bsSolid; Width := 2; End; End; Lbl1 := TRLLabel.Create(B_Pagehead); // Create a Label on PageHeader With Lbl1 do // Set Properties of Label; Begin Name := 'Lbl1'; Caption := Global.JobCode; AutoSize := True; Font.Style := [fsBold]; Top := CurrentTop; Left := CurrentLeft; CurrentLeft += Grid.Columns[i].Width + 15; Color := clYellow; Visible := True; End; MyReport.Preview(Nil); end; end.