Table of Contents

22.11.2 Report design

It has proven to be useful to record the layout of the report to be generated and to note the appropriate type, size specifications and possibly colors or other design specifications such as font and font heights for the report containers (ReportHBox, ReportVBox, ReportVPanel, ReportPanel) with the report controls they contain (which can also be report containers).

You should proceed as follows when designing a report:

22.11.2.1 Notes

The following notes are intended to help you implement layout planning with the Report Designer in Gambas. Try out the effect of the values of the individual properties on the layout of your report in the preview and change properties and values until you are satisfied with the result.

Notes on properties for the arrangement of report containers:

Notes on properties of the arrangement of report controls:

Attention: These report controls are not report containers.

22.11.2.2 ReportLabel and ReportTextLabel

The following descriptions for the ReportLabel also apply to the ReportTextLabel report control element. While the ReportLabel only prints text, the ReportTextLabel prints rich text.

Use the Data property of the String data type to provide the content of a ReportLabel control during the Data() event handler via the Data property.

The most important event is therefore Data ( argIndex As Integer ). This event is triggered when text is to be stored in the ReportLabel control. The argument `argIndex` returns the current index of the control. Index is a property of a ReportLabel.

Example:

Private hResult As Result
 
Public Sub Report_Open()
 
  ...
' Generates the result of a database query from a selected database table
  hResult = curDBConnection.Exec("SELECT * FROM tablename")
' Sets the number of repetitions of the three TextLabels in the container ReportHBox1
  ReportHBox1.DataCount = hResult.Count
  ...
 
End
 
Public Sub ReportLabelName_Data(Index As Integer)
 
' Use the `Index` argument to navigate through the query result.
  hResult.MoveTo(Index)
' The content of the database field "surname" is displayed in the "ReportLabelName" control element
  hResult.MoveTo(Index)
  Last.Data = hResult["nachname"]
' Last.Data = hResult!nachname     '-- Alternative
 
End
 
Public Sub ReportLabelVorname_Data(Index As Integer)
  hResult.MoveTo(Index)
  Last.Data = hResult["vorname"]
End
 
Public Sub ReportLabelGebDatum_Data(Index As Integer)
  hResult.MoveTo(Index)
  Last.Data = Format(hResult["gebdatum"], "d. mmmm yyyy") '-- Note the formatting
End

B1

Figure 22.11.2.2.1: Database report (excerpt)

Notes
If you set the UseField property in the ReportLabel to True, the component is initially backwards compatible with gb.report.The Range property is currently (August 2019) not used.

22.11.2.3 Class ReportImage

This class implements a report control that displays and prints an image.

22.11.2.3.1 Properties of the ReportImage class

The ReportImage class has the following properties, among others:

PropertyData typeDescription
ImageImageSets the image to be displayed in the ReportImage or returns the image.
FixedBooleanReturns or sets whether or not the image is displayed each time its parent element is called.
StretchIntegerThe Report-Image.Stretch property can assume one of the three values Report.Fill (2), Report.Proportional (1) or Report.None (0).

Table 22.11.2.3.1 : Properties of the ReportImage class

Note: If the Image width and Image height values are zero, the control behaves as if its property Autoresize = True.

Example: Inserting an image into a ReportImage

Public Sub Report_Open()
 
  Dim hReportImageLogo As Image  
  ...
  hReportImageLogo = Image.Load(".../logo-ide.png")
 
  ReportImage1.Image = hReportImageLogo
 
  ReportImage1.Stretch = Report.Proportional
 
' Output of the original values for image height and image width
  Print "Logo.H = "; hReportImageLogo.Height; " Pixel"
  Print "Logo.W = "; hReportImageLogo.Width; " Pixel"
 
End

The Gambas logo adorns the cover page of a report:

B2

Figure 22.11.2.3.1: Report cover page with image (excerpt)