Using repeated sections
Applies to JungleDocs for SharePoint 2010-2019.
For a similar tutorial for JungleDocs for Office 365, click here.
Repeated sections allow you to import multiple items from a list into a document template. Therefore, they are key to creating reports with JungleDocs. Using repeated sections, you can import not only selected items, but also a filtered or unfiltered view, or a whole list. In this tutorial, you will learn how to create repeated sections in Word and Excel templates.
Create a repeated section in a Word template
1. Create a table with at least two rows and select the second row (the first one will be used for titles). On the Developer tab, click the Rich Text Content Control button.
2. Click Properties. In a pop-up window, in the Tag field, enter the ReportItems function and click OK.
The selected row now becomes a repeated section. i.e., it will be repeated as many times as there are selected items when you run a JungleDocs rule. We recommend to copy and paste the Tag field value into the Title field. This way, you will be able to see the Tag field value without opening content control properties.
4. Add more content controls inside the ReportItems content control, and specify internal column names in the Tag field. In the example, the template is configured to retrieve the Title and Date column values for the selected SharePoint list items. For example, if you select three items, three rows will be created. Note that on the lower-left cell a placeholder text is entered for reference. When a document is generated, the placeholder text is replaced by the column value.
Create a repeated section in an Excel template
There are two ways to insert a repeated section in an Excel template.
Method 1: insert a comment
1. Right-click on the top-left cell and click Insert Comment.
2. Add a comment with the Repeater function.
The available syntaxes are:
- =Repeater(arg1; width; height)
- =Repeater(arg1; width)
- arg1 – command that returns a list of items, it should be a command that links your Excel template to specific data fields in your SharePoint sites.
The Repeater function supports the following arguments:
- arg1 Required. Any function that returns a set of items (e.g., GetView(), FindItems(), ReportItems()), for example:
- GetView("List Name"; "View Name") returns all items in your specified list view.
- FindItems("List Name"; "Column Name"; "Value") returns all items from your specified list that contain Value in your specified column "Column Name".
- width Optional. Maximum number of columns to be repeated. By default, its value is 0. It means that all columns will be copied in a row to the right from the current cell. For example, setting the width to 1 will only allow one (the first one) column to be repeated.
- height Optional. Maximum number of rows to be repeated. For example, setting the height to 2 will repeat 2 rows in the Excel sheet for every list entry in your SharePoint. By default, its value is 1.
3. If you want to copy list item values to your Excel sheet, you have to add the Repeater() command and add additional commands for every column you need to be copied:
In the example, a template is configured to repeat a region with a width of 6 columns, and 1 row for every list item, starting from cell A1. It will repeat as many times as there are items the GetView function returns. In each top cell (A1, A2 etc.), item IDs are displayed. In the lower cells (B1, B2 etc.), item Title column values are displayed.
Method 2: insert a table
Another way to create a repeated section in the template is by inserting a simple table.
1. Select cell A1 or A2. Then, on the ribbon, click Insert > Table.
2. Right-click the first content cell of the table and click Insert Comment. In the comment, enter the following formula: =Repeater(GetView("Tasks"; "AllItems")). This formula tells JungleDocs to retrieve items from the Tasks list, AllItems view. JungleDocs will extend this table to contain all columns from the view and will create a new row for each SharePoint list item.
You can also specify the columns containing values you want to be retrieved, and (or) calculations that will be done with those values in the document. To learn more, see Configuring Excel templates.