---
title: "Filling tables with array data"
description: "Fill tables with repeating array data in Docmosis templates, controlling layout, page breaks, headers, and row grouping for well-formatted documents."
canonical_url: "https://resources.docmosis.com/template-tutorials/tables"
last_reviewed: 2026-06-12
---
# Filling tables with array data
This example shows you how to use tables to display repeating data (eg: objects in an array).
By setting different table properties and paragraph properties you can control how the table lays out on the page when it is filled with data.
### Filling a table with data
The first row marked <<rr_ marks the start of a set of repeating rows. The placeholder word used after the rr_ identifies the top level array that holds the repeating data.
Docmosis will loop over the items in the array. The first block of data will be injected into the rows that follow until an <<er_ marker is found. Then the second block of data is injected - and so on - until all the data has been used.
The <<rr_ and <<er_ rows do not appear in the output file.
### Table and paragraph properties
When a table is filled with data it may expand and run over the page.
Consider the following questions:
- Should the table be allowed to break across a page?
- Should the whole table move to the top of the next page?
- Should the first row appear be used as a header row if the table runs over the page?
- Does it make sense for some rows to always appear together?
By setting different table properties and paragraph properties you can control how the table will display once it is filled with data.
### Row numbering
Docmosis contains two built-in variables, $rowidx and $rownum, that allow you to access/display the "number" of the data item that is currently being iterated.
- $rowidx starts from 0
- $rownum starts from 1
## Filling tables with array data - related json data
```json
{
"animals": [
{
"type": "Dog",
"name": "Rowlf",
"color": "Brown"
},
{
"type": "Frog",
"name": "Kermit",
"color": "Green"
},
{
"type": "Pig",
"name": "Miss Piggy",
"color": "Pink"
},
{
"type": "Bear",
"name": "Fozzie",
"color": "Brown"
},
{
"type": "Unknown",
"name": "Gonzo",
"color": "Purple"
}
]
}
```
## Filling tables with array data - example template syntax
# Tables - Part One
<<rr_ starts a group of **r**epeating **r**ows
<<er_ **e**nds a group of **r**ows
Rows that contain an <<rr_ or <<er_ instruction are removed.
The rows between the start/end markers are filled with the data.
**A Simple Table**
| <<rr_animals>> | | |
| --- | --- | --- |
| <<type>> | <<color>> | <<name>> |
| <<er_animals>> | | |
**Setting Table Properties**
| | The table below has:1. *“Allow row to break across pages”* - deselected for every row. 2. *“Repeat as header row at the top of each page” – selected for the first row.* 3. When the table is filled with data it will extend over the page. |
| --- | --- |
| This row will always appear as a Header Row. |
| --- |
| <<rr_animals>> |
| Everybody knows that<<name>> the <<type>>is <<color>> |
| <<er_>> |
**Built-in variables for numbering rows**
| Type | Value of “rowidx” | Value of “rownum” |
| --- | --- | --- |
| <<rr_animals>> | | |
| <<type>> | <<$rowidx>> | <<$rownum>> |
| <<er_>> | | |
**Setting Paragraph Properties**
| | The table below has the Paragraph Property:1. *“Keep with next”* - selected for the cells in row A. 2. *“Keep with next” – deselected for all the other cells.* This will ensure that row A “sticks” with row B if the table breaks over a page. |
| --- | --- |
| A table that runs over the page | | |
| --- | --- | --- |
| <<rr_animals>> | | |
| A | I want to keep the (A) row | <<name>> |
| B | With the (B) row | <<type>> |
| <<er_>> | | |
*Note: This example was set-up so that when the table is filled with data, even though there is enough room for the A row with “Miss Piggy” to fit on the bottom of the table on the previous page, it has been pulled on to the this page. The “Keep with next” property will ensure that it “sticks” to the B row.*