Configure layout and contents of reportsΒΆ

Typical procedure to configure a report

  1. Create a report

  2. Set the layout of a report.

  3. Add content:

  4. Customize document layout and references:

  5. Set the style sheet of a report

  6. 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.

  1. In Page size, set the desired format.

  2. In Page orientation set the desired orientation.

  3. 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

  1. In the Report object, right-click Sections, then click New and select Panel section.

  2. Right-click the Panel Section object, select New, then select the desired graphical object.

  3. Repeat the previous step for all the desired graphical objects.

  4. 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:

  1. In the Report object, right-click Sections, then click New and select Data grid section.

  2. 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.

  1. 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.

  2. To add graphical objects in the header, right-click the Header object then select New, then select the desired graphical object.

  3. Repeat the previous step for all the desired graphical objects.

  4. Customize the appearance and size of graphical objects through their properties.

  5. In the Objects editor, place the graphical objects in the desired position. This position is followed in the print phase.

Add page breaks

  1. Right-click Sections, then select New > Page break.

  2. Drag the Page break object between the sections where you want the page break.

Set the print references

  1. Add a Label object in the desired position of the Report.

  2. In the Label object, click image1 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

  1. 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.

  2. 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.

  1. In UI, add a Button object, then enter the desired text in the Text property (e.g. Generate report) and press ENTER.

  2. In Events, click image2 next to MouseClick Event: the Dynamic Link Window opens.

  3. 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.

  4. To set the file system location where the PDF should be saved, click image3 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).

  5. To set the locale of the report based on the session locale, click image4 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

  1. In UI, add a Label object in the desired container. The label will display the report printout result.

  2. In Project, click the object that invokes the Generate PDF method (see example in Configure the print of a report), then in Events click image5: the Dynamic Link Window opens.

  3. Expand Reports, then expand the report of interest and click the PDF generated event manager, then click Select: GeneratePDFCompletedEvent appears in Events.

  4. Click image6 next to GeneratePDFCompletedEvent: the Dynamic Link Window opens.

  5. Expand Commands > Commands for variables, click Set value, and then click Select.

  6. In VariableToModify, set a dynamic link with the Text property of the label created in step 1.

  7. Click image7 next to Value: the Dynamic Link Window opens.

  8. 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.

See also

Related concepts

Report

References

Reports