Report Structure

From DBReport wiki
Jump to: navigation, search

A report consists of bands that have elements which are stored in a definition file or a text string. The report is usually assigned a recordset from database and is printed or displayed on screen.


To understand how the DBReport works we need to understand the concept of bands.

A band is a box where we put objects, the most important band is “Detail” which is the only one who can not erase. This (Detail) is printed for each row or record of the RecordSet, eg. if we have 10 rows or records we have 10 bands Detail.

The band page header is printed first in the top of the page for each page in the report generated.

The band Page footer is printed on the bottom of the page for each page in the report generated.

The band Report header is printed after the band page header on the first page of the report.

The band Report footer is printed just after the last band printed on the final page of the report.

Group bands are bands that are printed before the band Detail like Group Header and then like Group Footer. They print to change the group (field of a recordset) or at the beginning of the report in the case of Group Header or end of the report in case of Group Footer. You can have as many group bands as needed.


The objects that can be placed in the bands are:

  • Labels: are texts like “Title Report” or the system date as “#date” or page number like “#pag” or parameters or formulas.
  • Fields: field of Recordset like “name” or “id”.
  • Lines: horizontal, vertical or oblique.
  • Rectangles Boxes or rounded rectangles.
  • Barcodes.
  • Images: Can be an image file, parameter or a RecordSet field.
  • Charts: Bar, lines, pie.
  • SubReports.

Note: Use XojoScript (RBScript) in formulas with “SetValue EXPRESSION” like:

SetValue (10+5)* RecNum+ (2* .1* RecNum)
' or
SetValue "String"
' or
SetValue ElementName* ParameterName
' or
SetValue Left(FieldName1, 10)+ " "+ FieldName2
' or
If FieldName1.InStr("cad")= 0 Then
    SetValue "No Contains cad"
    SetValue "Contains cad"


A parameter is assigned before calling the Designer or Print (“Logo” is an example, may be called as you want):

rpt.Parameter("Logo")= PictureObject
rpt.Parameter("CompanyName")= "My Company Name"


A property in DBReport is a special data used outside of report for whatever you want, example: save the database name or SQL string. Is used as metadata of report, but not in report itself.

rpt.Prop("sqlString")= "SELECT * FROM table"
rpt.Prop("databaseName")= "MyDB"

XML Definition file

The definition of report is in XML structure, you can change the extension of file whatever you like. This is an example:

<?xml version="1.0" encoding="UTF-8"?>
<DBReport Version="1.3.1007">
    <Band id="1" Name="ReporHeader1" Type="30"/>
    <Band id="2" Name="Detail" Height="20"/>
    <Band id="3" Name="ReportFooter1" Type="40" Height="58"/>
    <Element id="4" Name="Element1" BandId="1" Left="2" Top="7" Value="Title of report" OrderToShow="0"/>
    <Element id="5" Name="Element2" DataField="name" BandId="2" Left="4" Top="3" Type="20" OrderToShow="0"/>
    <Element id="6" Name="Element3" BandId="1" Left="455" Top="11" Value="#pag" OrderToShow="1"/>
    <Element id="7" Name="Element4" BandId="3" Left="235" Top="3" Value="#date" AlignH="1" OrderToShow="0"/>

XML Preferences file

DBReport saves preferences like position of Designer window or zoom in a preferences.xml file in: SpecialFolder.ApplicationData.Child("DBReport").