Printing the total in the header

Top  Previous  Next

Usually you will print total values on the footer bands (such as data footer, group footer, etc). It's a natural printing order because when you print the total, its value is properly calculated and is ready to use. However, in some cases, you would need the total to be printed on the header (for example, on the group header). If you try to do this, you will see a zero value. At this moment, when you print a total, it is not calculated yet.

 

To solve this problem, FastReport has a feature called "delayed print". The "Text" object has a property called "ProcessAt" which can have one of the following values:

 

Value

Description

Default

The default printing mode. This is the default value.

ReportFinished

The object's value will be calculated at the end of the report.

ReportPageFinished

The object's value will be calculated when all bands in the page will be finished.

PageFinished

The object's value will be calculated at the end of the page.

ColumnFinished

The object's value will be calculated at the end of the column.

DataFinished

The object's value will be calculated at the end of the data band (when its footer is printed).

GroupFinished

The object's value will be calculated at the end of the group (when its footer is printed).

 

Let's look at how it works. Put the "Text" object which prints the total, on the group header. Set the "ProcessAt" property of the "Text" object to "GroupFinished":

 

ProcessAt1

 

When you run the report, FastReport will do the following:

 

it will print the group header. The total value will be printed as 0 (wrong), but FastReport will remember this object to process it later;
it will print all data rows;
it will print the group footer. At this moment, FastReport will take the object that was printed in the group header, and process it again to print the correct total value.

 

The prepared report will be as follows:

 

ProcessAt2

 

Using other values of the "ProcessAt" property, you may print the report total in the report title (set ProcessAt = ReportFinished), or print the page total in the page header (set ProcessAt = PageFinished).

 

The delayed print feature will not work if you turn on the report file cache ("Report/Options..." menu, "Use file cache" checkbox).