Create or design simple master report with Fortes Report

Friends, now a days designing reports are necessary for a software developer as it is a most important part of any software product and is usually the most profitable part of the business. In this blog I will explain how to create / design a report with Fortes Report. 

In my last blog I have provided detail information about Fortes Report and its components used to design reports. So 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 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 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 a TRLExpressionbar component to form to use Dataformula property for report components

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

DataSource = srcmaster
Title = 'CUSTOMER REPORT'
ExpressionParser = RLExpressionParser1

7. Put TRLBand component on RLReport1 named RLBand1 for header and set following properties

BandType = btHeader
        Borders.DrawBottom = True

8. Put following components on header band RLBand1 and set following properties

RLLabel1: TRLLabel
Left = 217
Top = 0
Width = 284
Height = 32
Align = faCenterTop
Alignment = taCenter
Caption = 'CUSTOMER REPORT'
Font.Style = [fsUnderline]

RLSystemInfo1: TRLSystemInfo
Left = 631
Top = 0
Width = 87
Height = 16
Align = faRightTop
Alignment = taRightJustify
Info = itPageNumber

RLSystemInfo2: TRLSystemInfo
Left = 0
Top = 0
Width = 60
Height = 16
Align = faLeftTop
Info = itFullDate

RLLabel2: TRLLabel
Left = 3
Top = 53
Width = 66
Height = 16
Caption = 'CUST NO.'
Font.Style = [fsBold]

RLLabel3: TRLLabel
Left = 104
Top = 53
Width = 41
Height = 16
Caption = 'NAME'
Font.Style = [fsBold]

RLLabel4: TRLLabel
Left = 376
Top = 53
Width = 66
Height = 16
Caption = 'ADDRESS'
Font.Style = [fsBold]
9. Add another TRLBand component named RLband2 and set as detail band

BandType = btDetail

10. Add following components to detail band RLBand2 and set following properties

RLDBText1: TRLDBText
Left = 3
Top = 1
Width = 57
Height = 16
AutoSize = False
DataField = 'CUSTNO'
DataSource = srcmaster
RLDBText2: TRLDBText
Left = 104
Top = 1
Width = 217
Height = 16
AutoSize = False
DataField = 'COMPANY'
DataSource = srcmaster
RLDBMemo1: TRLDBMemo
Left = 376
Top = 1
Width = 273
Height = 16
Behavior = [beSiteExpander]
DataFormula = 'Addr1 +'#39' '#39'+City + '#39' '#39'+Phone'
DataSource = srcmaster

11. Add another TRLBand component named RLband3 and set as footer band

BandType = btFooter
        Borders.DrawTop = True

12. Add following components to footer band RLBand3 and set following properties


RLLabel5: TRLLabel
Left = 298
Top = 24
Width = 121
Height = 16
Align = faCenterBottom
Caption = 'DIGITAL SIGNED....'
13. Put report filter components on form to save report in different format during preview

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

12. 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 := Form1.ADOConnection1;
qrymaster.SQL.Clear;
qrymaster.SQL.Text := 'SELECT * FROM CUSTOMER';
qrymaster.Open;
srcmaster.DataSet := qrymaster;

RLReport1.PreviewModal;

Close;
end;

13. 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...



Comments

  1. Hi, I do according to given steps.
    Result: Preview did not work.
    I received run-time error: Bitmap image is not valid. ???

    When I changed line: RLReport1.PreviewModal to:
    RLReport1.Print it worked OK but without preview.
    Can you help?
    Thanks, Ante, Croatia

    ReplyDelete

Post a Comment

Popular posts from this blog

ShellExecute in Delphi

How to send Email in Delphi?

Drawing Shapes in Delphi