Documill Dynamo

repeatWorksheet

A child command of composeXLSXContent that iterates through all items of a Collection and produces as many worksheets as there are items in the collection.

Parent commands

  • composeXLSXContent
    Required. Defines the Excel file that the repeatWorksheet command modifies.

Attributes

value



Required

Value type

EL-evaluated

Yes

Collection, Map, Data Item

Yes

This attribute defines the container whose contents the command will iterate through. While this container is primarily expected to be a Collection, two other types of values are also accepted.

The three types are handled in the following ways:

  • If the value is a Collection, repeatWorksheet iterates through the items in it in their proper order.  

  • If the value is a Map, repeatWorksheet iterates through its entries. The item of every round is therefore a Map entry that allows both the key and the value to be accessed. Note that the order in which the entries appear in is, in most cases, not consistent and basically random.

  • If the value is a Data Item, repeatWorksheet performs just one loop round, with the Data Item being the item of the round.  

var



Required

Value type

EL-evaluated

Yes

String

No

The value of this attribute defines the name of the local context variable that holds the current item of the loop.

varStatus



Required

Value type

EL-evaluated

No

String

No

Defines the name of the variable that holds a Loop Status value. Loop Status has the properties count, first, last and index. A new value is generated for every iteration of the loop.

Property count is the number of the iteration starting from 1.
Property index is the same as count with the difference that it starts from 0.
Property first is a Boolean true during the first round of the loop. Note that if roundTest causes the first item of the iteration to be skipped, this will never be true.
Property last is a Boolean true during the last round of the loop. Note that if roundTest causes the last item of the iteration to be skipped, this will never be true.

roundTest



Required

Value type

EL-evaluated

No

Boolean

Yes

This attribute can be used to define a condition for skipping certain iteration rounds. This attribute's expression is evaluated at the start of every round and if it doesn't resolve into true, the current item and loop round is skipped, resulting in no copy of the slide being produced.

If undefined, no iteration rounds are skipped.

worksheet



Required

Value type

EL-evaluated

Yes

String, Number

No

Defines the worksheet that will be repeated. Value can be the sheet name (String) or index (Number, first sheet is 1).

sheetName



Required

Value type

EL-evaluated

Yes

String, Number

No

Defines the name of the produced sheet - evaluated separately for every iterated item, so it can use expressions with the “var” in it. If not defined, the repeated sheets will have the name of the original repeated sheet with a number suffix.

The repeatWorksheet command can be used to create Excel files with multiple worksheets based on the amount of records in related lists, custom SOQL queries, custom collections within the template.
This is especially useful for product data sheets and significantly reduces manual data input.

In the sample below (image and source), repeatWorksheet is used to create one worksheet per each item in 'oppLineItems' (collection produced from relatedList):

image-20261130-121239.png
<xlex:composeXLSXContent var="file" template="${file}" title="${documentTitle}" customProperties="${properties}">
                <xlex:repeatWorksheet value="${oppLineItems}"
                                      var="oppLineItem"
                                      worksheet="1"
                                      sheetName="${sheetStatusVar.getCount()}"
                                      varStatus="sheetStatusVar"
                                      roundTest="${oppLineItem.showProduct == true}" />
              </xlex:composeXLSXContent>

Resulting in an Excel with as many sheets as there are items in the Collection:

image-20261130-121552.png