Fortes Report and Components.


Fortes Report
A best alternative to Quick Report. It’s totally free and supports latest Delphi versions

The Fortes Report is a powerful report generator available as a package of components for Delphi looks very similar to the Quick Report. In Fortes Report, the reports are composed of bands that have specific functions to print data. You define groupings, sublevels and totals simply by hierarchical relationship between bands. Moreover, the Fortes Report has a rich palette of components to print text, image, barcode and export components etc.

How to install Fortes Report in Delphi ?
For Delphi DX or later versions we can use GetItPackage Manager to install. For lower Delphi version download latest code from following links and follow the steps.


Then go to Packages folder and Open frce.dpk package. Then right click compile and Build. Then again right click and select Install to install in IDE.


And after install in Delphi IDE you can see Fortes report components.


TRLReport is main report component used to design report.


Some of important properties…

Property Name
Description
Background
Used to set report background image
Borders
Used to set report borders
Color
To set report background color
CompositeOptions
Used when we use composite reports
Numberpages        = for page numbers
ResetPageNumber = to reset page number for next report
DataSource
Sets master TDataSource component which is linked with a dataset and whose records will be printed. For this we have to put a Detail Band (TRLband with BandType = btDetail) and then TRLDbtexts to show data.
DefaultFilter
Set default export printer filter which will show during save or print
Degrade
To apply gradient effect to background color
Direction = ddNone, ddHorizental, ddVertical
OppositeColor = clAnything
FirstPageNumber
Starting Page Number
Margins
Used to set report page margins
NextReport
Next report component if we want to show multiple report at a time
PageSetup
Used to set page options like Page orientation and size
PreviewOptions
Used to set preview form settings
To apply the changes, use Defaults = pdIgnoreDefaults
PrintEmpty
If True then it will print report yet no data exists
RangeCount
Define total number of records. It will effect when RecordRange = rrNextN
RecordRange
Defines how to show records and by default its rrAllRecords
Title
To show report title if we use RLSysInfo component Info=riTitle
Transparent
If True then removed background effects and prints on white color
UnLimitedHeight
If True then prints all data on single page with unlimited page height

Events
Description
AfterPrint
Fires after report preview/print finished
BeforePrint
Fires before report preview/print start
onDataCount
Fires on every record print and DataCount variable returns total record count.
onDataRecord
Fires on every record print and can be used to make a choice which record need to print. RecordAction variable defines which record to print.
onFilterText
Fires on every data print and can be used to make a decision to print the data or not
onNeeddata
Fires on every record print and can be used to check more record exists or not to print.
onPageEnding
Fires on last page print
onPageStarting
Fires on first page print

TRLBand
As Fortes report is composed of bands, so bands play important role in report design. Bands used as contained for report components. We can put Labels, texts, images on band to show data. Bands can be different types like header, footer, column header, column footer, detail etc. TRLBand.BandType property defines which type of band we want to use.


Property Name
Description
Autosize
To set band auto height
Background
To set band background image
CarbonCopies
Defines how many time same will print. By default 1.
BandType
This is an important property which defines band type

btDetail    = sets detail band that prints actual data retrieved from database. It gets data from report component’s datasource’s dataset records. It used to print master data in case of master-detail reports.

btColumnHeader = sets column header band that used to print column titles. Prints before detail band print at top of every page.

btColumnFooter = sets column footer band that used to print footer details. Prints after detail band print at bottom of every page

btHeader = sets header band that used to print header details like Report Title, company details etc. Prints before detail band print at top of every page.

btFooter = sets footer band that used to print footer details like company moto. Prints after detail band print at bottom of every page

btTitle = sets Title band that used to print report title details for a report like a Sales report title. Prints on first page only before detail data print

btSummary = sets Summary band that used to print report summary details like totals. Prints at end of page after all detail data print.

Color
Set background color
Degrade
To apply gradient effect to background color
Direction = ddNone, ddHorizental, ddVertical
OppositeColor = clAnything
Font
To set all child component font
GreenBarColor
Defines alternate row color
GreenBarPrint
If true then only GreenBarColor applied and will show alternate color
Pagebreaking
Defines the page break.
boNone            =  no page break
boAfterprint    =  page break after band print
boBeforePrint  =  page break before band print
Transparent
If True then removed background effects and prints on white color

Events
Description
AfterPrint
Fires after band print finished
BeforePrint
Fires before band print start

TRLDetailGrid
This band is used to print data in row / column format. It is very suitable for Label print.


Property
Description
ColCount
Defines number of columns data need to print
ColSpacing
Space between columns
ColWidth
Sets column’s width
Organization
Defines how to print data i.e in row order or column order.
goInColumns  = prints data in column order
goInRows       = prints data in row order

TRLGroup
This band is used to print grouping records. We generally group some records as per specific fields and print them. We also totals for the grouped records.


Property
Description
DataFields
Defines grouping fields on which grouping will be done on records.
We can use a Field Name or Field Names separated with semicolon ; like
Cust_No
Dept_Type;Cust_No
Dataformula
This is also used to define grouping. But here instead of field names we use a formula that based on field values like. Cust_no
IntegralHeight
If True then it defines that Group band with all child band will print together. For example if there is little at page bottom and it prints Detail column header and prints other on next page then it may misguide a customer then in that case we can set this TRUE so that it will print all the band together on next page.

TRLSubDetail
This band is used to print Sub-detail records when we design a master-detail report. We have to use TRLBand for master data print with BandType=btdetail and TRLSubDetail band can be used to print detail data when parent child relation.


Property
Description
DataSource
Defines detail TDatasource component which is linked with a dataset that having detail data in case of master-detail report. It generally having child records for a master record.
Positioning
Defines the position of TRLSubdetail band. It shows when to print sub-detail band data.
IntegralHeight
If True then it defines that Subdetail band with all child band will print together. For example if there is little at page bottom and it prints Detail column header and prints other on next page then it may misguide a customer then in that case we can set this TRUE so that it will print all the band together on next page.

Events
Description
AfterPrint
Fires after report preview/print finished
BeforePrint
Fires before report preview/print start
onDataCount
Fires on every record print and DataCount variable returns total record count.
onDataRecord
Fires on every record print and can be used to make a choice which record need to print. RecordAction variable defines which record to print.
onNeeddata
Fires on every record print and can be used to check more record exists or not to print.

TRLLabel
This component used to print a text. We must put on a band.
Property
Description
Align
Defines label alignment in band
Alignment
Sets Caption alignment horizontally
Layout
Sets Caption alignment vertically
Autosize
Sets label autosize as per the caption
Borders
Sets label border with colors
Color
Sets background color
Font
Sets label font style and color
Holder
Uses to link another component for alignment. For example we have put a TRLLabel on column header and TRLDbtext on detail. Then we can set TRLDbtext Secondholder to TRLLabel. Then when we move TRLLabel then it also moves TRLDBtext. So it help to rearrange everything.
HoldStyle
This defines how second holder component will be aligned
SecondHolder
Uses to link another component for alignment. For example we have put a TRLLabel on column header and TRLDbtext on detail. Then we can set TRLDbtext Secondholder to TRLLabel. Then when we move TRLLabel then it also moves TRLDBtext. So it help to rearrange everything.
SecondHoldStyle
This defines how second holder component will be aligned

Events
Description
Beforeprint
Fires before label print
Afterprint
Fires after label print

TRLAngleLabel
Property
Description
Angle
Defines angle for label caption

TRLDBText
Component to print actual data that fetched from database. We have to set Datasource and Datafield property to print data.
Property
Description
Datasource
Sets Tdatasource component whose linked dataset data to be print
DataField
Field name whose data to be print
Dataformula
We can use a formula with field name like 
item_rate * item_qty
Displaymask
Sets display mask for data like dd/mm/yyyy, hh:nn:ss, 0.00 etc
Text
Sets an additional text with linked field value like No : 1, where “1” is field value and “No :” is text

TRLMemo / TRLRichText    
This components used to print multi line data.
Property
Description
Behavior
    beSiteExpander
If True then it will resize the band where it is put as per the size of memo
Lines
To set multi line text to print
Wordwrap
Wraps the text to new line as per width

TRLDBMemo / TRLDBRichText   
This is just like TRLMemo / TRlRichtext component but here instead of assigning Lines value we use Datasource and DataField property to show fetched database data
Property
Description
Datasource
Sets Tdatasource component whose linked dataset data to be print
DataField
Field name whose data to be print
Dataformula
We can use a formula with field name like 
Address1 +', '+ City + ', '+ PhoneNo

TRLImage
This component used to show images and it supports all type of images.
Property
Description
Picture
To load a new picture. At runtime we can use like
TRLImage.Picture.loadfromfile(‘fileName’);
AutoSize
Set TRLImage size as per image size
Center
Set image at center of component
Scale
If True then Zooms the image as per component size
Stretch
If true then resizes the image as per component size

TRLDBImage
This component is just like TRLImage but we used DataSource and DataField property to get image data from database.
Property
Description
Datasource
Sets Tdatasource component whose linked dataset data to be print
DataField
Field name whose data to be print

TRLSysInfo
This is a useful component used to print system data like current date, current time, report title, page number, page count etc.
Property
Description
Info
Defines which system data to print. Values can be
itCarbonCopy   – prints Carbon copy number
itCopyNo          - Sequential Log Copy Number
itDate               – prints Current report date  
itDetailCount   – prints Sub Detail record count as per master
itFullDate         – prints full date with time
itHour               – prints current report time
itJunction         - Page junction flag. Indicates whether the report continues on the following pages
itLastPageNumber – prints last page of the rpeort
itMend              - Page junction flag. Indicates whether the current page is the continuation of previous pages
itNow               – prints current date and time
itPageNumber  – prints current page number
itPagePreview  - Current page number and total page of the report
itTitle                – prints report Title
itRecNo             – prints current record number  
Text
Adds an additional text with Info data like Page : 1, where “1” is page number value and “No :” is text

TRLDraw
This component is used to draw shapes and lines.
Property
Description
Angle
Sets shape angle
Brush
Used to fill color in shape. We can use Color and Style to see the effect.
Center
Aligns the shape to center
DrawData
This is used to draw custom shape
Drawheight
Sets drawing area height
DrawWidth
Set drawing area width
Drawkind
Defines what type of shape need to draw
dkLine            – draws Line
dkRectangle   – draws rectangle
dkTriangle      – draws triangle
dkElipse         – draws elipse
dkArrow         – draws arrow
dkCustom       – to draws custom image as per DrawData
Pen
Used to draw shape borders. We can apply border color, width and style

TRLDBResult  
This component is used to print total and summary values like Sum, Count, Min, Max Avg etc. We have to assign Datasource and DataField value to calculate summary values. We can put these components in Group Footer and Summary bands to print group total or summary total.
Property
Description
ComputeNulls
Calculate Null values also
Datasource
Sets Tdatasource component whose linked dataset data to be print
DataField
Field name whose data to be print
Dataformula
We can use a formula with field name like Copy(cust_name, 1, 1)
Displaymask
Sets display mask for data like dd/mm/yyyy, hh:nn:ss, 0.00 etc
Info
Defines which summary value to print
riAverage    - prints Average value
riCount       – prints total record count
riFirst         – prints first printed value
riLast          – prints last printed value
riMax          – prints Max value
riMin           – prints Min value
riSum          – prints Sum value
riFirstText  – prints first printed text
riLastText   - prints last printed text
riSimple      - Useful for solving formulas with built-in functions
Text
Sets an additional text with linked field value like No : 1, where “1” is field value and “No :” is text

TRLPanel  
This component is used just like TPanel component which contains some child components. It will move all child components when we change position.
Property
Description
Behavior
    beSiteExpander
If True then it will resize the band where it is put as per the size of memo
Borders
Set Panel borders

TRLBarcode 
This is used to print Barcode. We have to set Caption property value to print barcode.
Property
Description
Caption
Defines Barcode value
InvalidCode
Defines how it should print barcode if invalid value
Module
Defines barcode lines width
Orientation
Defines barcode orientation for lines arrangement like LeftToRight,
Toptobottom etc.
Ration
Defines barcode ratio
ShowText
Defines how barcode text should show like both text and type or only text or nothing

TRLDBBarcode 
This is like TRLBarcode component used to print Barcode but here we have to get the value from TDatasource dataset. So we have to set Datasource or DataField property value.
Property
Description
Datasource
Sets Tdatasource component whose linked dataset data to be print
DataField
Field name whose data to be print
Dataformula
We can use a formula with field name like Copy(cust_name, 1, 1)

Export Filters Component
These components are used to export report data into different file format like PDF, XLS RTF etc. To get use of these filters we just need to put the Filters with Report components on that same form
TRLRichFilter     =             RTF Format
TRLPDFFilter      =             PDF Format
TRLHTMLFilter   =             HTML Format
TRLXLSFilter      =             Excel XLS Format for old Excel versions
TRLXLSXFilter    =             Excel XLSX format for latest Excel versions

TRLExpressionBar
This component is used to function DataFormula property for some components. We need to put this component on same for where report component exists and need to link RLReport1.ExpressionParser = RLExpressionParser1. Then rest of thing will be maintained by component itself.
Link to report
     RLReport1.ExpressionParser = RLExpressionParser1
RLDBText use DataFormula.
     RLDBText1.DataFormuls := addr1 +' '+city + ' '+Phone;
     RLDBText2.DataFormuls := Rate * Quantity;

TRLPreviewSetup  
This component is used to change report preview form settings. We just need to drop the component on form and set required property values. Then rest of things will be done by the component itself and to check the effect open a report preview.
Property
Description
BorderIcons
Set report preview form icons like minimize, maximize and help
Caption
Sets preview form caption
EditOptions
Provides functionality to edit report data at runtime during preview
eoCanReposition = to allow reposition at runtime
eoCanResizeItems = to allow resize items at runtime
eoEditText = to allow edit text of items at runtime
eoCandeleteItems = to allow delete items at runtime
EnableButtons
Controls preview form buttons enable / disable
FormStyle
Sets preview form style like MDIChild or normal
Position
Sets preview form initial loading position
Showmodal
Preview form will show as modal if we call Preview function. We can call PreviewModal also
ZoomFactor
Sets initial report Zoom value

TRLPreview 
This component can be used to design our own preview form. It generally shows a prepared report on preview screen. It is just like TScrollBox component and to show a TRLRpeort in TRLPreview we have to write code
      RLReport1.Preview(RLPreview1);  
                             or 
      RLPreview1.Pages := RLReport1.Pages; 
                             or 
      RLPreview1.Pages.LoadFromFile('C:\ReportFile1.rpf'); 
      to load report from a saved file.

We can set some other TRLPreview property and methods at runtime to make fully functional.

Now lets create some reports with using Fortes Report.

1. Create or Design master report with Fortes Report
2. Create or Design master detail report with Fortes Report
3. Create or Design Grouping report with Fortes Report
4. Create or Design Labels with Fortes Report
5. Create or Design own Preview Form using Fortes report 

Comments

  1. Great blog. Thanks

    Any idea about TRLRichText justify alignment (I think RickEdit version 3 or superior)

    ReplyDelete
  2. Many thanks for this helpful overview of FortesReport. You suggest that the DisplayMask property of the TRLDBText component should work with masks such as dd/mm/yyyy, hh:nn:ss, 0.00 etc.
    I can only get it to apply masks to format float or integer values. If I set DisplayMask to hh:nn:ss the report prints "hh:nn:ss" rather than a formatted time. Is this a bug or have you found a way to use DisplayMask to format dates and times. I've had to resort to using the BeforePrint event handler to apply the formatting with code.

    ReplyDelete
  3. I can use FortesReport for FireMonkey ?

    ReplyDelete

Post a Comment

Popular posts from this blog

ShellExecute in Delphi

MS Excel Automation in Delphi

Drawing Shapes in Delphi