---
title: Templates in Excel
description: Set up, create, and manage reusable query templates in the Databricks Excel Add-in, including template groups, mandatory filters, and Unity Catalog permissions.
canonical_url: https://docs.databricks.com/aws/en/integrations/excel/templates
---

# Templates in Excel

The Databricks Excel Add-in lets you save a reusable set of imports as a template in Unity Catalog. Create templates from your saved imports, organize them into groups that you share with specific users, and import a template's imports into any workbook. A template stores only the query definitions, not the imported data, so each person who uses it runs the queries with their own Unity Catalog permissions.

This page explains how to set up, create, and manage templates. To import data from a template, see [Import from a template](https://docs.databricks.com/aws/en/integrations/excel/query-data.md#use-template).

## <a id="set-up-templates" />Set up templates

A workspace admin or a user with the `CREATE CATALOG` privilege must set up templates in the Databricks Excel Add-in:

1. In the Databricks Add-in pane in Excel, click the **Saved imports** tab, then click the ![File document icon.](https://docs.databricks.com/aws/en/images/product-icons/FileDocumentIcon.svg) **Templates** icon.
2. Enter a name for your first template group. Template groups organize related templates.
3. Choose who can use templates in the group:
   * **Give all account users read access**: Everyone in the account can use templates in the group.
   * **Give read access to specific users**: Enter one or more email addresses.
4. Choose who can create templates in the group:
   * **Give all account users write access**: Everyone in the account can create templates in the group.
   * **Give write access to specific users**: Enter one or more email addresses.
5. Click **Set up**. This creates a `spreadsheet_templates` catalog and an `excel_templates` schema in your connected metastore. Setup grants all account users `USE CATALOG` on the catalog, and `USE SCHEMA` and `CREATE TABLE` on the schema. It also grants `SELECT` on the template group to the users you gave read access, and `SELECT` and `MODIFY` to the users you gave write access.

> [!IMPORTANT]
>
> The sharing settings you choose during setup and when you create a group control who can use templates (`SELECT`) and who can create or edit templates (`MODIFY`) in that group. If you don't choose the account-wide option, only the users whose email addresses you enter have access. A workspace admin can give access to other users, such as users added after setup, by granting `SELECT` on the template group in Databricks. To let a user create or edit templates, the admin must grant `SELECT` and `MODIFY`. See [Manage privileges in Unity Catalog](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/index.md).

## <a id="create-group" />Create a template group

After templates are set up, any user can create template groups. Setup grants all account users `CREATE TABLE` on the `spreadsheet_templates.excel_templates` schema, which is what creating a group requires. To create or edit templates in a group, you need write access (`MODIFY`) on that group.

Template groups organize related templates and control who can access them. When you create a group, you choose which users can use the templates in it and which users can create templates in it.

To create a template group:

1. In the **Saved imports** tab, click the ![File document icon.](https://docs.databricks.com/aws/en/images/product-icons/FileDocumentIcon.svg) **Templates** icon, then click **New group**.
2. Enter a group name using letters, numbers, and underscores. The name can't start with a number.
3. Choose who can use the group:
   * **Give all account users read access**: Everyone in the account can use templates in the group.
   * **Give read access to specific users**: Enter one or more email addresses.
4. Choose who can create templates in the group:
   * **Give all account users write access**: Everyone in the account can create templates in the group.
   * **Give write access to specific users**: Enter one or more email addresses.
5. Click **Create group**.

## <a id="create-template" />Create a template

Create a template from the imports already saved in your workbook:

1. In the **Saved imports** tab, click the ![File document icon.](https://docs.databricks.com/aws/en/images/product-icons/FileDocumentIcon.svg) **Templates** icon, then click **New template**.
2. Select a template group and enter a name for the template.
3. Select the saved imports to include.
4. (Optional) Under **Set mandatory filters**, mark filters on the selected imports as mandatory. Users of the template can change a mandatory filter's values but can't remove the filter or change its type.
5. Click **Create template**.

## <a id="manage-templates" />Manage templates

On the **Templates** page, you can do the following:

* Expand a template to see the imports it contains.
* Edit a template to add or remove imports, or to change which filters are mandatory.
* Delete a template.

Editing and deleting a template require write access (`MODIFY`) on the template group.

## Limitations

Templates have the following limitations:

* You can add imports to or remove imports from a template, but you can't edit an import's query text from within the template. To change the query, edit the import in your workbook, remove it from the template, and add the edited import back.
* A template can include only imports saved in the workbook where you create it.
* Mandatory filters are available only for table and pivot imports that have filters. Query imports don't have mandatory filters.
* Importing a template adds each import to a new sheet, and a template import doesn't include the original import's scheduled refresh settings. To keep the imported data up to date, [schedule a refresh](https://docs.databricks.com/aws/en/integrations/excel/schedule-refresh.md) on the new imports.

## Additional resources

* [Import and query data using the Databricks Excel Add-in](https://docs.databricks.com/aws/en/integrations/excel/query-data.md)
