Skip to content

Parameters

Overview

OpenReport allows to declare a parameter and assign it a value. The "parameters" instance lists all "parameter" instances applicable for the "document". The "parameter" instance specifies the parameter's settings. Parameter value can be set manually or can be obtained using the "source" instance.

Back to homepage


Manual

This specification declares parameter "year" using "parameter_name" property. The "parameter_type" property specifies the method the parameter is set: "manual" or "source". With "manual" the parameter is specified manually using "parameter_value" property.

- document:
    name: document.docx
    parameters:
        - parameter: 
            parameter_name: year
            parameter_type: manual
            parameter_value: 2025
        - parameter:
            # ...
    structure:
        # ...

Parameter usage

The declared parameter can be referenced throughout the document using the @parameter{parameter_name} format:

- document:
    name: document.docx
    parameters:
        - parameter: 
            parameter_name: year
            parameter_type: manual
            parameter_value: 2025
    structure:
        - text:
            body: Happy New @parameter{year} Year!
This specification adds to the document:
Happy New 2025 Year!

Back to homepage


Source

With "source" the parameter is specified using the "source" instance. The value of "parameter" is the output of "source" instance.

- document:
    name: document.docx
    parameters:
      - parameter:
          parameter_name: total_sales
          parameter_type: source
          source:
            output: text
            source_type: python
            python_executable: calculate_total_sales
    structure:
        # ...

This specification declares parameter "total_sales" using "parameter_name" property. The "parameter_type" property specifies the method the parameter is set: "source". The value of parameter is an output of user-defined function 'calculate_total_sales'.


Parameter usage

Similarly, the parameter value can be addressed within the rest of the document:

- document:
    name: document.docx
    parameters:
      - parameter:
          parameter_name: total_sales
          parameter_type: source
          source:
            output: text
            source_type: python
            python_executable: calculate_total_sales
    structure:
      - text: 
          body: Total sales for year @parameter{year} is @parameter{total_sales}.
If 'calculate_total_sales' outputs 250,000, the document will contain:
Total sales for year 2025 is 250,000.
Back to homepage


Required properties

Required properties for "parameter" instance is "parameter_name", "parameter_type" and depending on "parameter_type" value either "parameter_value":

- parameter:
    parameter_name: 
    parameter_type: manual
    parameter_value:

Or "source":

- parameter:
    parameter_name: 
    parameter_type: source
    source:
      # ...

Continue to iterations

Back to top

Back to homepage