# Fill a branded Excel template | DRE

> Design the workbook in Excel; DRE fills the cells and tables and keeps your styling.

[← All use cases](https://getdre.com/#use-cases)

# Fill a branded Excel template

Finance has a monthly pack in the company’s look, with logos, colours, charts and formulas. Keep that workbook as a template and tell DRE where each query’s data goes. DRE writes the numbers and keeps the styling, extends the template’s totals over the new rows, and fills its row formulas down.

Recorded from a real run: the command, then the filled workbook in Excel with each kind of binding highlighted.

Recorded from a real run: the command, then the filled workbook in Excel with each kind of binding highlighted.

![The Summary sheet of the filled Monthly pack workbook in Excel, with the formula =SUM(C$6:C6) showing for the selected cell](https://getdre.com/media/monthly_pack/excel.webp)

The workbook DRE wrote from the template, opened in Excel (real screenshot, light mode, zoom 85% to fit the window). The footer note is the template’s own.

[↓ Download the filled workbook (monthly\_pack.xlsx)](https://getdre.com/media/downloads/monthly_pack.xlsx)

reports/formats/xlsx\_template/xlsx\_template.yml

```yaml
queries:
  - {query: pack_kpis}
  - {query: pack_regions}
  - {query: pack_categories}
  - {query: pack_detail, tab_name: Detail}   # not bound: becomes a plain sheet after the template's own
output:
  format: xlsx
  template:
    file: monthly_pack.xlsx          # found in templates/
    bindings:
      - {sheet: Summary, cell: B2, value: "{{ period(var('period')).start.date }} to {{ period(var('period')).end.date }}"}
      - {sheet: Summary, cell: B3, query: pack_kpis, column: total_net}
      - {sheet: Summary, cell: D3, query: pack_kpis, column: orders}
      - {sheet: Summary, cell: F2, value: "{{ var('company') }}"}
      - {sheet: Summary, query: pack_regions, anchor: A6, header: false, columns: [region_name, orders, net]}
      - {sheet: Categories, query: pack_categories, anchor: A3}
  destination: {profile: local, path: "out/monthly_pack.xlsx"}
```

reports/formats/xlsx\_template/pack\_kpis.sql

```sql
{% set p = period(var('period')) %}
select sum(net_amount) as total_net, count(distinct order_id) as orders
from {{ ref('paid_order_facts') }}
where order_date between '{{ p.start.date }}' and '{{ p.end.date }}'
```

terminal

```bash
dre run xlsx_template --var period=last_month
```

### What to notice

-   A binding is either a single cell (a fixed value, or a column of a query’s first row) or a table block at an anchor cell.
-   Number formats and fills from the template are kept; a column format in YAML replaces only the number format.
-   The template’s own SUM rows grow with the data, and its row formulas are filled down.
-   Queries you don’t bind still become sheets of their own after the template’s.

### In the docs

-   [xlsx options and templates →](https://getdre.com/docs/plugins/)
