🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators opendocumentreportasblob
This page was created by Hans.karlsen on 2019-03-15. Last edited by Wikiadmin on 2026-07-29.

You can use opendocumentreportasblob in an OCL expression when your reporting ViewModel must render an OpenDocument or HTML-based report and return the generated file content as a Blob.

What the operator does

opendocumentreportasblob runs the OpenDocument reporting logic for the supplied ViewModel and returns the rendered document as a Blob. A Blob is binary file content, so use this operator when the next step needs the generated file content rather than an HTML document opened in the browser.

The operator uses the same reporting engine as OpenDocument reporting. The reporting ViewModel supplies both the data that replaces template tags and the information used to locate the template.

Syntax

ResultAsBlob := self.opendocumentreportasblob(ReportRoot.ViewModels.ReportingViewmodel)
Part Meaning
self The root object for the reporting ViewModel.
ReportRoot The class that owns the reporting ViewModel in this example.
ViewModels The method that retrieves the class's ViewModels.
ReportingViewmodel The reporting ViewModel to render. Replace this with the name of your ViewModel.
ResultAsBlob A variable that receives the generated document content.

Use the operator

  1. Create a reporting ViewModel that exposes the values required by your template. For example, if a template contains %CustomerName%, the ViewModel must provide an attribute named CustomerName.
  2. Configure the ViewModel with the template location. OpenDocument templates can be retrieved from a Blob attribute, a URL, or the local file system. See OpenDocument reporting for the supported template setup.
  3. Add an OCL expression that calls opendocumentreportasblob on the report root and passes the reporting ViewModel.
  4. Store or pass on the returned Blob where your application needs the generated file content.

For example, the following expression renders the ViewModel named ReportingViewmodel and assigns the resulting document content to ResultAsBlob:

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

Template formats and tags

The reporting engine supports OpenDocument Text (.odt) and OpenDocument Spreadsheet (.ods) templates. It can also process well-formed HTML templates ending in .htm or .html. For HTML and XML template behavior, see HtmlReport.

Use percent-delimited ViewModel attribute names as template tags. For example, an attribute named CustomerName is referenced as %CustomerName% in the template. To inspect the available tag names for an OpenDocument template, use %meta% as described in OpenDocument reporting.

Choose the right reporting operator

Requirement Use
Return generated document content for later handling opendocumentreportasblob
Render the report and open the resulting HTML in the browser opendocumentreportshow
Process an XHTML string and return XHTML as a string XHtmlReportAsString; see HtmlReport

Important considerations

  • The template tag must match the reporting ViewModel attribute name. Copy tag names including the percent signs when working from generated meta data.
  • In OpenDocument templates, formatting changes or line breaks within a tag can prevent the reporting engine from recognizing it. Follow the template-editing guidance in OpenDocument reporting.
  • For .ods templates, values represented by tags are interpreted as text unless the reporting ViewModel uses the documented naming suffixes for numeric or percentage values. See OpenDocument reporting.

See also