The report component gb.report2 offers the option of structurally arranging and printing data from different sources. You can define the layout of a report in the IDE with the Report Designer.
Please note! The graphical report designer is not a WYSIWYG editor. The individual report controls such as Report.Label or Report.Image - within a report section - can be inserted into report containers such as Report.HBox or Report.Panel. However, the properties of the report controls that are then defined are only partially displayed. You can check the selected layout and design at any time using a report preview and a control printout in order to make corrections. It can be helpful to set the Report.Debug property to True, as the boundaries of all objects contained in the report are drawn in this mode.
As an alternative to using the Report Designer, you can also define the complete layout and design of a report via the source code. However, this always harbours the risk of entering incorrect values for selected properties or not adhering to the specified syntax, which cannot happen in the Report Designer. The Report Designer can be used if the layout is extensive with many containers and many report control elements. For example, to define a border around a ReportPanel1 (left, right, top and bottom 5 mm, top left and bottom right corners additionally rounded with a radius of 5 mm) with a linear black-red-yellow colour gradient (linear gradient), you need this value assignment of the ReportPanel1.Border property in the source code:
ReportPanel.Border = ReportBorder["Top:5mm LinearGradient(0,0.04,0,1,[#000000,#FFFF00,#FF0000],[0,1,0.5]); Bottom:5mm LinearGradient(0,0.04,0,1,[#000000,#FFFF00,#FF0000],[0,1,0.5]); Left:5mm LinearGradient(0,0.04,0,1,[#000000,#FFFF00,#FF0000],[0,1,0.5]); Right:5mm LinearGradient(0,0.04,0,1,[#000000,#FFFF00,#FF0000],[0,1,0.5]); TopLeftCorner:5mm;TopRightCorner:0mm;BottomRightCorner:5mm;BottomLeftCorner:0mm"]
The component reimplements the Align, Arrange and Line classes and implements a number of report classes:
Report, ReportBorder, ReportBoxShadow, ReportBrush, ReportContainer, ReportControl, ReportDrawingArea, ReportFrame, ReportHBox, ReportImage, ReportLabel, ReportLine, ReportMargin, ReportPadding, ReportPageBreak, ReportPanel, ReportSection, ReportSizeHints, ReportSizeParser, ReportSvgImage, ReportTextLabel, ReportVBox, ReportView, ReportVPanel, TSizeParse.
A description of the properties for the Align, Arrange and Line classes can be found under
https://www.gambas-buch.de/doku.php?id=k20:k20.7:start&s[]=align#klasse_align https://www.gambas-buch.de/doku.php?id=k20:k20.7:start&s[]=align#klasse_arrange http://gambaswiki.org/wiki/comp/gb.qt4/line
The most important class of the gb.report2 component is Report, because this class represents a report.
The class behaves like a read-only array and returns a virtual object of the ReportSection data type for the specified index:
Dim hReport As Report Dim hReportSection As ReportSection hReportSection = hReport [ Index As Integer ]
Please note that many properties are defined via other classes such as ReportPadding, ReportBrush or ReportBoxShadow. For example, the `Report.Border` property is of the ReportBorder type. This means that these properties apply specifically to the report and are not necessarily comparable with the same properties of other control elements.
The Report class has the following properties:
Property | Data type | Description |
---|---|---|
BackGround | ReportBrush | Returns or sets the background colour used by the report. |
Border | ReportBorder | Returns or sets the border of the report. |
BoxShadow | ReportBoxShadow | Returns or sets the shadow used by the report. |
Brush | ReportBrush | Returns or sets the brush used for drawing. The default brush has a monochrome, opaque black colour. |
Children | ReportControl[] | Returns a collection of all control elements contained in the container. |
Count | Integer | Returns or sets the number of sections in the report. |
Data | Object | n/a |
DataCount | Integer | Supplies or sets the number of repetitions required to read all data. |
DataIndex | Integer | Returns the value of the repeat counter. |
Debug | Boolean | For the value True, the reports are generated in debug mode. This mode draws the boundaries of all objects contained in the report. The default is False. The value can also be read out. |
Expand | Boolean | Delivers or sets whether a control expands if it is contained in a container. The default is True. |
Fixed | Boolean | Returns or sets whether a control is displayed each time its parent element is called. For the value False, the report control is only displayed once. |
Font | Font | Supplies or sets the font used to draw text in the control. To change the font control at runtime, you can do the following: Use the font property of another existing control or create a font object from a string that describes the font and assign it to the report control. You can find more information at http://www.gambaswiki.org/wiki/comp/gb.qt4/font/_get. |
ForceNewPage | Boolean | For the value True, a new page is inserted into the report. |
Height | String ! | Returns or sets the height used by the report. The height is of data type float. Permissible units are: mm, cm, in, ft, px, pt and specifications in %. Example: Height = “1.3cm”. |
Width | String ! | Delivers or sets the width of the report. |
ID | Integer | Delivers the handle of the report. |
Index | Integer | n/a |
Name | String | Sets the name of the report. |
OnePiece | Boolean | This property causes the content of the container to be printed on the same page for the value True. |
Orientation | Integer | Delivers or sets the orientation of the layout of the report. The value of this property is either Printer.Landscape or Printer.Portrait. |
Padding | ReportPadding | Delivers or sets the distance that separates a subordinate report control from the edge of the container. This applies to a report control as well as to text. Example: Report1.Padding = ReportPadding[“Top:14mm;Bottom:10mm;Left:10mm;Right:14mm”] |
PageCount | Integer | Delivers the current number of pages in the report. |
Paper | Integer | Returns or sets the paper format used for printing. Paper.Custom is returned if the Printer.PaperWidth or Printer.PaperHeight properties have been defined by the user. Example: Report1.Paper = Printer.A5. Default is A4. |
Report | Report | Delivers the report for a report control. |
Resolution | Integer | Delivers or sets the report resolution in DPI (Dots Per Inches). If the value is zero, the value of the device is used. |
Scale | Float | Changes the drawing scale. It assumes a value between 0 and 1. You can also read out the value. |
Spacing | String | Supplies or sets the spacing that separates the report controls in a report container. Permitted units are: mm, cm, in, ft, px, pt and specifications in %. Example: Report1.HBox1.Spacing = “5mm” |
Tag | Variant | Supplies or sets the control tag. This property is intended for the programmer and is not used by the component. Tag can be any value of the data type Variant. |
Text | String | Determines the title of a section of a report. |
Visible | Boolean | Determines whether the report is visible or not. |
Table 22.11.0.1.1 : Properties of the Report class
The Paper property can have one of the following values
The Report class has these methods:
Method | Return type | Description |
---|---|---|
Clear ( ) | - | Removes all report controls from the current report. |
Clone ( ) | Report | A new instance of the current report is returned. |
Layout ( ) | - | Forces the layout or repeats the layout calculations for the current report. |
Paint ( Page As Integer ) | - | Draws the specified report page. Note that the first page is 1 and not 0. |
Preview ( ) | - | Opens a preview window with the current report. You can then print the report on a printer or print it to a PDF file, the path of which you can freely select in the dialogue. |
Print ( [ hPrinter As Printer ] ) | - | Prints the report. If the printer is specified (optional), the report is printed immediately on the specified printer. Otherwise, a dialogue opens because Printer.Configure() is called internally if at least one printer exists as the default printer in the system. |
Table 22.11.0.1.2 : Methods of the Report class