🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.

__HIDECREDIT__

Create reports from ViewModel data

You can create reports by processing an OpenDocument template, adding data from a ViewModel, and producing a resulting document file.

Report data and templates

The ViewModel provides the data used by the report. Templates can be retrieved from:

  • a BLOB attribute in a modeled class;
  • a URL, such as a document server; or
  • the local file system.

The reporting ViewModel also has attributes with specific names that provide information to the reporting functionality. The supplied sources do not define all of those attribute names or their required configuration.

Create an OpenDocument report

OpenDocument reporting supports these template formats:

  • OpenDocument Text (.odt)
  • OpenDocument Spreadsheet (.ods)

Create a ViewModel containing the data required by the report, create an OpenDocument template, and place report tags in the template. The documentation describes data tags in the form %Something%, corresponding to ViewModel columns.

To discover the available tags for a document, place %meta% in the template and generate the report. For recognition, %meta% must be the first string in its element and is case-sensitive. Copy generated tag names, including their percent signs, rather than manually editing them.

Generate the report

Use opendocumentreportasblob when the report result is needed as bytes. It takes an array of bytes as input and output.

ResultAsBlob := self.opendocumentreportasblob(ReportRoot.ViewModels.ReportingViewmodel)

Use opendocumentreportshow to perform the same operation and open the resulting HTML in the browser.

self.opendocumentreportshow(ReportRoot.ViewModels.ReportingViewmodel)

Template guidance

Template type Guidance
.odt edited in Microsoft Word Font changes, including invisible changes, can interfere with detection of content to replace. If this occurs, copy the tag, including percent signs, and paste it back as plain text. Line breaks can also interfere with tag detection; use Word text-section settings with no line breaks.
.ods Data tags are interpreted as text unless the report ViewModel uses the documented naming suffixes for values that Excel should interpret as floats or percentages. The supplied excerpt refers to these suffixes but does not list them.
.htm or .html The reporting logic expects a well-formed HTML document. See HtmlReport for further information.

Scope

This page covers the documented template-and-ViewModel reporting workflow. The supplied sources do not establish an end-user report designer, detailed HTML-report APIs, or integrations with external business-intelligence products.

See also