Configure layout and contents of reportsΒΆ
Typical procedure to configure a report
Add content:
Customize document layout and references:
Configure the print:
Create a report
In Project, right-click the Reports folder, then select New > Report: the new Report object appears, made up of the Header, Sections and Footer objects, and a style sheet for formatting the report contents.
Set the layout of a report
The page layout setting concerns all the report pages.
In Page size, set the desired format.
In Page orientation set the desired orientation.
In Left margin, Top margin, Right margin and Bottom margin, set the desired margins in centimeters.
Note
by setting a value for the page margins, when objects are added in Header, Sections and Footer, they are automatically positioned within the set margins.
Add a section for graphic or text content
In the Report object, right-click Sections, then click New and select Panel section.
Right-click the Panel Section object, select New, then select the desired graphical object.
Repeat the previous step for all the desired graphical objects.
Customize the appearance, size and position of graphical objects through their properties.
Adds a Data grid
If you want to add a table that presents data from a database in the report, do the following:
In the Report object, right-click Sections, then click New and select Data grid section.
In the Data grid section object properties, set the source of the data to be displayed and the desired columns (see Data grid).
Note
in the PDF, the table size and column width are automatically set based on the width of the Data grid.
Customize the header and footer of a report
The Header and Footer objects have the same properties. The following procedure refers to the Header object, but is valid for both objects.
To define the height of the report header, inside the Report object click Header, then in the Height property set the desired value in millimeters.
To add graphical objects in the header, right-click the Header object then select New, then select the desired graphical object.
Repeat the previous step for all the desired graphical objects.
Customize the appearance and size of graphical objects through their properties.
In the Objects editor, place the graphical objects in the desired position. This position is followed in the print phase.
Add page breaks
Right-click Sections, then select New > Page break.
Drag the Page break object between the sections where you want the page break.
Set the print references
Add a Label object in the desired position of the Report.
In the Label object, click next to the Text property, then inside the Report object select Current page number, Total page number or Print date and time depending on the desired date.
Set the style sheet of a report
In the Reports folder, click the desired Style sheet object and set the properties.
Note
Q Studio automatically creates a style sheet for the reports when the first Report object is created in the project. To create alternative additional style sheets, copy and paste the existing style sheet.
To use the style sheet, in the desired Report object, in the StyleSheet property select the style sheet.
Configure the print of a report
The generation of the report in PDF format takes place via the Generate PDF method of the Report object. To start a print of the PDF at runtime, an object must be configured, in the example below a Button, that invokes the Generate PDF method.
In UI, add a Button object, then enter the desired text in the Text property (e.g. Generate report) and press ENTER.
In Events, click next to MouseClick Event: the Dynamic Link Window opens.
Expand the Reports node, then expand the report of interest and click the Generate PDF > Select method: the Generate PDF method input arguments appear in MouseClick Event.
To set the file system location where the PDF should be saved, click next to OutputPath and enter the file system path and name of the final document (for example %APPLICATIONDIR%/MyReport.pdf), or click Browse then select the path of an existing PDF (which will be overwritten).
To set the locale of the report based on the session locale, click next to LocaleId, then expand in Aliases > {Session} > Session, then click ActualLocaleIds, then Select.
Configure the display of the result of the print of a report
In UI, add a Label object in the desired container. The label will display the report printout result.
In Project, click the object that invokes the Generate PDF method (see example in Configure the print of a report), then in Events click : the Dynamic Link Window opens.
Expand Reports, then expand the report of interest and click the PDF generated event manager, then click Select: GeneratePDFCompletedEvent appears in Events.
Click next to GeneratePDFCompletedEvent: the Dynamic Link Window opens.
Expand Commands > Commands for variables, click Set value, and then click Select.
In VariableToModify, set a dynamic link with the Text property of the label created in step 1.
Click next to Value: the Dynamic Link Window opens.
Expand the node of the object being changed, then select PDF generatedHandler > EventArguments > Result.
Note
for details on the values of the Result variable, see PDF generated.