How to create a report template.

Back

This sample will create a simple report from the Customers database that comes with Delphi. The template is created with MS Word 2013.

The bands in the report is defined with comments. Report fields is defined with field codes.

1.
Open an empty document in MS Word.
Enter the report page header. This text will be printed on top of each report page. Use tabs to separate the report columns.
2.
Select the heading text.
3.
Create a comment.
In MS Word:
  • Select the Review tab
  • On the Comments pane. Click New Comment.
4.
Add band parameters.
This band will be a page header band.
  • Write "-band". This must be the first line and defines the comment as report band. Without it, the comment is ignored.
  • Write "Name: [PgHeader]". The name, in this example "PgHeader" can be any name that is not used elsewhere.
  • Write "Type: PageHeader". Type is the band type, in this case a page header.
5.
Create the fields of the band.
A band field is defined with field codes.
  • Place the curor under Company and select the Insert tab.
  • On the Text pane, click Quick Parts.
  • Select Field...
  • Browse to MergeField and select it.
  • In Field name, write "Company". This is the name of the database field.
  • Click OK
6.
Repeat 5 for the rest of the fields.
7.
Edit Fields
To edit a field, place the cursor in the field text. It will become gray. Press Shift+F9. You can now edit the field codes. The text "\* MERGEFORMAT" is a field parameter used by MSWord that can be deleted. AXWReport uses other field parameters that you can read about in the documentation. Press Shift+F9 again to clode the field editor.
8.
Create the data set band
Repeat 3 and 4 to create a comment, but select the field codes instead.
  • In the Type: parameter, write "DataSet" as this is a data set band.
  • Add a DataSet parameter and write "tblCustomers". This parameter can be omitted if the database fields are in the data set property of the TAXWReport object.

Copyright (c) 2021 Axolot Data