> For the complete documentation index, see [llms.txt](https://support.attackforge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.attackforge.com/app/modules/reporting/template-tables.md).

# Template - Tables

## Overview

Tables in your report template can grow to fit your project data. Put a loop around a table row, and ReportGen repeats that row once for each item, such as each vulnerability or affected asset. Add conditions to colour-code rows or cells, or to show different rows for different data.

Help, examples and tips are also on the [ReportGen GitHub support site](https://github.com/AttackForge/ReportGen).

<figure><img src="https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FRCny2iEo0yPeHMWLU5HS%2Ftemplate-tables-at-a-glance.svg?alt=media&amp;token=496bef24-fd82-4fc2-8aa4-91f0dfaba7c1" alt=""><figcaption></figcaption></figure>

## Why it matters

* **Tables that fit every project.** A findings table has the right number of rows whether the project has 3 vulnerabilities or 300.
* **Easier to read.** Colour-coding by priority or status helps readers find what matters first.
* **One template for every report.** No need to add or delete rows by hand after the report is generated.

## Who uses it

| Who                         | To                                                                    |
| --------------------------- | --------------------------------------------------------------------- |
| **Report template authors** | Build findings, asset and summary tables that grow with the data      |
| **Consultancies and MSSPs** | Give clients consistent, colour-coded tables in their preferred style |
| **Security teams**          | Produce tables that are easy to scan for remediation owners           |

## Add a table with repeating rows

You can add tables with repeating rows. Put the opening loop tag in the first cell of a row, and the closing tag `{/}` in the last cell of the same row. ReportGen repeats the row once for each item in the list.

1. **Insert a table in your Word template.** Add a header row with your column names.
2. **Add the repeating row.** In the first cell, start the loop, such as `{#vulnerabilities}`. In the last cell, close it with `{/}`.
3. **Add tags to each cell** for the data you want, such as `{title}` or `{priority}`.
4. **Generate the report.** The row repeats for every vulnerability.

**Example** — a findings table.

| Title                       | Priority     | Status        |
| --------------------------- | ------------ | ------------- |
| `{#vulnerabilities}{title}` | `{priority}` | `{status}{/}` |

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FrCyF2cmVjbwmfIMti6ZV%2FScreen%20Shot%202021-10-17%20at%201.55.35%20pm.png?alt=media\&token=0801eb32-9f2c-4e82-9d2e-fc90b66d14b5)

The output in your report will appear as follows:

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FRbpfhPI7qenV810sDiCZ%2FScreen%20Shot%202021-10-17%20at%201.58.54%20pm.png?alt=media\&token=a291bab3-e5b1-4e66-92a5-59f76cc1fdf6)

{% hint style="info" %}
**Important:** The opening and closing tags must be in the same row. If they're in different rows, ReportGen repeats all the rows between them as a group.
{% endhint %}

## Add logic to tables

You can combine this with conditions to colour-code the relevant sections.

Add one row for each condition, and shade each row in Word the colour you want. Each row shows only the vulnerabilities that match its condition.

**Example** — colour-code rows by priority.

| Row shading in Word | Title cell                                                      | Priority cell   |
| ------------------- | --------------------------------------------------------------- | --------------- |
| Red                 | `{#vulnerabilities \| filter:'priority === "Critical"'}{title}` | `{priority}{/}` |
| Orange              | `{#vulnerabilities \| filter:'priority === "High"'}{title}`     | `{priority}{/}` |
| Yellow              | `{#vulnerabilities \| filter:'priority === "Medium"'}{title}`   | `{priority}{/}` |
| Green               | `{#vulnerabilities \| filter:'priority === "Low"'}{title}`      | `{priority}{/}` |
| Blue                | `{#vulnerabilities \| filter:'priority === "Info"'}{title}`     | `{priority}{/}` |

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FEEE24WtVqGKju4jkbtlz%2FScreen%20Shot%202021-10-17%20at%201.52.02%20pm.png?alt=media\&token=275d7a45-3b03-4d6c-9f8a-2cf615921c8e)

The output will appear as follows:

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2F7pzwbb695Qr8dYJLN76H%2FScreen%20Shot%202021-10-17%20at%202.09.15%20pm.png?alt=media\&token=24d1f804-f86c-46f8-8a42-f0392c8d4258)

This also sorts the table by priority, because each priority's rows come out together.

## Use dynamic rows and conditions

You can add custom logic to your table rows, for example to render the background of a cell different based on certain conditions.

The example above shades a whole row. To shade only one cell, such as the priority cell, put the conditions inside that cell.

**Example** — a status cell that reads differently for open and closed findings:

| Title                       | Status                                                                        |
| --------------------------- | ----------------------------------------------------------------------------- |
| `{#vulnerabilities}{title}` | `{#status == "Open"}Open – action needed{/}{#status == "Closed"}Closed{/}{/}` |

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2FgkVCWJcGfg1ENcZWd2pJ%2FScreen%20Shot%202022-06-07%20at%201.25.22%20am.png?alt=media\&token=97187311-c95a-479d-9da3-39f13e38ca78)

![](https://372186556-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8s1QY2Q6YTHB4a6DMu%2Fuploads%2Fk7JrwMjxWFKd2Qs853cP%2FScreen%20Shot%202021-11-19%20at%209.00.21%20am.png?alt=media\&token=e97ec5b0-bbbd-4f94-a1f2-4d60da426895)

## Sort, filter and number table rows

Table loops work with [template filters](https://support.attackforge.com/app/modules/reporting/template-filters) and [template functions](https://support.attackforge.com/app/modules/reporting/template-functions).

| To                                                      | Put this in the first cell (example)                                                     |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Sort rows by CVSS score, highest first                  | `{#vulnerabilities \| sort:["cvssv3_base_score:desc"]}`                                  |
| Show only Critical findings that are easily exploitable | `{#vulnerabilities \| filter:'easily_exploitable === true AND priority === "Critical"'}` |
| Show only findings on external assets                   | `{#vulnerabilities \| filterBy:'AffectedAssetCustomTags':['Source:External']}`           |
| Number each row                                         | `{#vulnerabilities}{$index}`                                                             |

#### Show a row when there's nothing to list

Add a second row below the repeating row, using `^` to show it only when the list is empty.

| Title                                              | Priority        |
| -------------------------------------------------- | --------------- |
| `{#vulnerabilities}{title}`                        | `{priority}{/}` |
| `{^vulnerabilities}No vulnerabilities were found.` | `{/}`           |

## Style tables in rich-text fields

This page is about tables you build in your Word template. Tables that testers add in AttackForge's rich-text editor, such as in a proof of concept, are styled with tag options instead. See [Template Styles](https://support.attackforge.com/app/modules/reporting/template-styles).

## Tips

* **Keep the loop in one row.** Open it in the first cell and close it in the last cell.
* **Shade rows in Word, not in tags.** Set the shading on each conditional row, and ReportGen keeps it.
* **Add a "nothing found" row** with `{^...}`, so an empty table doesn't look like a mistake.
* **Sort and filter in the opening tag,** rather than adding extra rows.
* **Repeat the header row on each page.** In Word, select the header row and turn on **Repeat as header row at the top of each page** in Table Properties.
* **Stop rows breaking across pages.** In Word's Table Properties, turn off **Allow row to break across pages**.
* **Use straight quotes (") in tags.** Turn off Word's smart quotes when writing tags.

## FAQ

**Why didn't my row repeat?** Check that the opening tag is in the first cell and `{/}` is in the last cell of the same row, and that the list name is spelt correctly. Use `$help` to check the data.

**Can a repeating row span several rows?** Yes. If the loop opens in one row and closes in a later row, all the rows between repeat together.

**How do I colour-code cells?** Add one row for each condition and shade it in Word, or put conditions inside a single cell. See the examples above.

**How do I sort the table?** Add `sort` to the opening tag, such as `{#vulnerabilities | sort:["cvssv3_base_score:desc"]}`.

**What happens when there's no data?** The repeating row disappears. Add a `{^...}` row to show a message instead.

**Can I style tables that testers add in the rich-text editor?** Yes, with table options on the `{@..._styled}` tag. See [Template Styles](https://support.attackforge.com/app/modules/reporting/template-styles).

### Related pages

* [Reporting overview](https://support.attackforge.com/app/modules/reporting/overview)
* [Template options](https://support.attackforge.com/app/modules/reporting/template-options)
* [Template functions](https://support.attackforge.com/app/modules/reporting/template-functions)
* [Template filters](https://support.attackforge.com/app/modules/reporting/template-filters)
* [Template styles](https://support.attackforge.com/app/modules/reporting/template-styles)
* [ReportGen on GitHub](https://github.com/AttackForge/ReportGen)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://support.attackforge.com/app/modules/reporting/template-tables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
