User Tools

Site Tools


Sidebar

Databases

k22:k22.11:k22.11.5:start

22.11.5 Report project - database table, diagram and text

This chapter presents a database report project with three sections.

  • Section 1 represents the cover page.
  • A database table is inserted in the second section.
  • A summary of the basic results from a text file is included in the third section.

As it is well known that a picture can say more than a thousand words, a line diagram generated from the displayed database data is inserted into the second section as an image in the report in addition to the tabular display of the database data.

22.11.5.1 Section 1 - Cover

The layout of the first section ‘Cover’ is defined first. The cover page does not have a page number.

BILD 1

Figure 22.11.5.1.1: Section 1

22.11.5.2 Section 2 - Data

The layout of the second section ‘Data’ contains a heading, a DB table and a diagram. The footer shows a reference to the page number and the number of all pages.

BILD 2

Figure 22.11.5.2.1: Section 2

Notes

  • Sections 1 and 2 each contain a ReportVBox whose Expand property is set to True. This ensures that in section 1 the 4 report details are moved to the bottom of the page and in section 2 the last row of data on the page is moved to the footer (dynamic spacer).
  • The number of data rows to be displayed in section 2 (top) is determined by the number of data records available in the current database result. If there is not enough space on a page, a new page is automatically created for the data records still to be displayed. For this reason, you only need to define the layout of the first data row (ReportHBox with 4 ReportLabels), which then also applies to all data records.
  • The diagram in the second section is generated internally in the programme from the database data and inserted after the database table:
...
 
'-- Data from the DB table is drawn in a diagram and inserted into the report as an image.
 
    CreateChart()
 
    rImageChart.Data = $hImage
    rImageChart.Alignment = Align.Center
    rImageChart.Stretch = Report.Proportional
...
 
Public Sub CreateChart()
 
    SetChartGeneral()
    SetChartType()
    SetChartColors()
    SetChartLegend()
    SetChartXAxis()
    SetChartYAxis()
    SetChartValues()
 
'-- Drawing on a picture
    Paint.Begin($hImage)
      $hLineChart.Draw()
    Paint.End()
 
End
...

22.11.5.3 Section 3 - Summary

In the summary in section 3, text from a text file is inserted into a ReportTextLabel in a TextContainer of type ReportVBox after a heading.

BILD 3

Figure 22.11.5.3.1: Section 3

Notes

  • In order to display longer text in a report, some preparations must be made. Firstly, determine how many lines of text are required to display the text completely, depending on the text, the font used and the width of the TextContainer.
  • Please note: The (usable) width and height of the TextContainer depends on the values set for the Margin and Padding properties of the higher-level report controls and the TextContainer itself!

The finished database report is impressive:

BILD 4

Figure 22.11.5.3.2: Database report (preview)

The complete source code for this report project is also made available to you in a project archive - including the SQLite database used.

Download

Project

Download

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k22/k22.11/k22.11.5/start.txt · Last modified: 17.05.2024 by emma

Page Tools