Create or design Labels with Fortes Report


In my last blog I have explained how to design grouping reports by using Fortes Report and its components. In this blog I will show you how to design a Label report to print Labels in row or column order. And for more detail about Fortes Report please visit Fortes Report and Components.

Here I have created a project which contains simple report to show Customer details in Labels and you can download the sample DB from link download dbdemos.db. I have saved the DB in C:\Test1 folder.

So now lets design Customer Label report with Fortes Report components.

1. First create a project and add a form to the project lets say Unit1 (Form1).

2. Add a TADOConnection component to the form named connmain and set connection string.
 ConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\demos.mdb;Persist Security Info=False'
 LoginPrompt = False
 Provider = 'Microsoft.Jet.OLEDB.4.0'

3. Add a TADOQuery component to form named qrymaster and set 

 Connection = connmain

4. Add a TADODatasource component to form named srcmaster and set 

 Dataset = qrymaster

5. Add TRLReport component to form named RLReport1 which is main report component and set following porperties

 DataSource = srcmaster
 Title = 'CUSTOMER LABEL REPORT'

6. Put TRLDetailGrid component on RLReport1 named RLDetailGrid1 for Labels band and set following properties

RLDetailGrid1: TRLDetailGrid
  Left = 38
  Top = 38
  Width = 718
  Height = 115
  ColCount = 3
  ColSpacing = 3.000000000000000000
  ColWidth = 60.000000000000000000
  Degrade.Direction = ddHorizontal
  Degrade.OppositeColor = clAqua

7. Put following components on band RLDetailGrid1 and set following properties

   RLDraw1: TRLDraw
    Left = 6
    Top = 6
    Width = 215
    Height = 102
    Pen.Color = clRed
    Pen.Style = psDashDot
 
   RLDBText1: TRLDBText
    Left = 11
    Top = 10
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'CUSTNO'
    DataSource = srcmaster
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBlack
    Font.Height = -13
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentFont = False
    Text = ''
 
   RLDBText2: TRLDBText
    Left = 11
    Top = 26
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'COMPANY'
    DataSource = srcmaster
    Text = ''
 
   RLDBText3: TRLDBText
    Left = 11
    Top = 42
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'ADDR1'
    DataSource = srcmaster
    Text = ''
 
   RLDBText4: TRLDBText
    Left = 11
    Top = 58
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'CITY'
    DataSource = srcmaster
    Text = ''
 
   RLDBText5: TRLDBText
    Left = 11
    Top = 74
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'COUNTRY'
    DataSource = srcmaster
    Text = ''
 
   RLDBText6: TRLDBText
    Left = 11
    Top = 90
    Width = 205
    Height = 16
    AutoSize = False
    DataField = 'PHONENO'
    DataSource = srcmaster
    Text = ''

8. Put report filter components on form to save report in different format during preview

 RLRichFilter1: TRLRichFilter;
 RLPDFFilter1: TRLPDFFilter;
 RLXLSFilter1: TRLXLSFilter;
 RLHTMLFilter1: TRLHTMLFilter;

9. Now Customer Report design is ready and add codes to show report. Here I have added a procedure ShowReport to Form1 to preview report.

 procedure TForm1.ShowReport;
 begin
  qrymaster.Connection :=ADOConnection1;
  qrymaster.SQL.Clear;
  qrymaster.SQL.Text := 'SELECT * FROM CUSTOMER';
  qrymaster.Open;
  srcmaster.DataSet := qrymaster;

  RLReport1.PreviewModal;

  Close;
 end;

10. Now I will add another form to the same project and will set that as main form. Then on a button click I will show the report.

So add a new form Form2 and put a TButton component name Customer1 on that form. And on button click write following code.

uses
   Form1; 
 ......
 ......
 procedure TForm2.Customer1Click(Sender: TObject);
 begin
  Form1 := TForm1.Create(Self);

  Form1.ShowReport;
 end;

Form design time...




Report preview...



Create or design simple master report with Fortes Report

Create or Design master detail report with Fortes Report

Create or Design grouping report with Fortes Report

Create or design own Preview Form using Fortes report 

Comments

Popular posts from this blog

ShellExecute in Delphi

MS Excel Automation in Delphi

Drawing Shapes in Delphi