All multi-line directives such as #if, #else, #elseif, #foreach, and #macro must be used under the following conditions:

  1. The beginning and ending statements must be declared within a single cell. The two figures below show two samples of invalid usage of the multi-line statements between cells.


    A sample of an invalid multi-line statement.


    Another sample of an invalid multi-line statement.

    Since the body of the #if statement is contained in the cell A2, this cell will not be generated if the condition is not true (the element type is not “usecase”). Due to the constraints of spreadsheet document structure, the number of cells in a column must be equal to the number of cells in all columns, and the number of cells in a row must be equal to the number of cells in all rows.

    The codes in the figure above will break the structure of a spreadsheet document. The two figures below demonstrate two samples of valid usage of the multi-line statements.


    A sample of a valid usage of multi-line statements.

    Another sample of a valid usage of multi-line statements.

  2. VTL Macro must be declared within a single cell. Do not insert the multi-cell recorded macros in a single cell, see figure below.

    Invalid Usage of Macro Statement in ODS

A sample of an invalid usage of a VTL macro.

The macro will copy all contents between #macro and #end. Cells and rows will be included in the macro as well. Once this record has been inserted, the macro content will break the document’s structure.

Creating Data for Multiple Rows

The #foreach directive can only be used in a single cell record. To create data for multiple rows, use the #forrow directive instead, see figure below.

The #forrow directive being used to create data for multiple rows.

As shown in figure below, the output will be:

The results of running the code from the figure above.

Creating Data for Multiple Columns

#forcol is used to create data for multiple columns, see figure below. This statement can be used with #forrow (see the sample from the “Other Document” template).

The #forcol directive being used to create data for multiple columns.

From the usage of #forcol shown in figure below, the output will be:

The results of running the code from the figure above.