# Named Cell Templates

## Content

SpreadJS Designer provides a visual interface for applying and managing Named Cell Templates.
With Designer, you can:

* Apply templates to selected ranges
* Create reusable templates
* Modify, duplicate, or delete templates
* Use built-in preset templates

Templates created or modified in Designer are stored in the workbook and are fully compatible with the SpreadJS runtime API.
For detailed rule behavior, see [Named Cell Templates (Runtime Feature)](/spreadjs/docs/features/workbook/named-cell-templates).

## Accessing Named Cell Templates

1. Select a target cell or range.
2. Go to the Home tab.
3. In the Styles group, click Named Templates.

![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260421.11144a.png?width=800)
The template gallery opens and displays available templates.
![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260421.0087cc.png?width=800)

## Template Gallery

The gallery displays all templates available in the current workbook.
Templates are organized into:

* **Built-in Templates** — Provided by SpreadJS Designer.
* **Custom Templates** — Created by users and stored in the workbook.
    ![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260331.5f94aa.png?width=800)

>type=note
> **Notes:**
>
> * If a custom template has the same name as a built-in template, the custom template takes precedence and the built-in template is hidden. If the custom template is deleted, the built-in template becomes visible again.
> * Each template includes a preview thumbnail. When the gallery is opened for the first time, a loading indicator is shown while previews are generated. Thumbnails refresh automatically when the workbook theme changes.
> * In TableSheet, GanttSheet, and DataSource scopes, sheet-level state templates (such as Active Row, Hover Row, and Crosshair) are hidden from the gallery because they rely on worksheet-level state behavior.

For a detailed description of each built-in template and its included components, see [Built-in Named Cell Template Gallery](/spreadjs/docs/spreadjs-designer-component/spdesignerwork/named-cell-templates/built-in-named-cell-template-gallery).

## Applying Templates

### Worksheet & ReportSheet

1. Select the target range.
2. Open the Named Templates gallery.
3. Click a template.

The template is applied immediately. Multiple selections are supported.
![ApplyingTemplateToWorksheet..gif](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/ApplyingTemplateToWorksheet.-20260421.7310b9.gif?width=800)

### TableSheet & GanttSheet

1. Open the Column Settings panel.
2. In the Styles group, select Named Templates.
3. Choose a template.

![ApplyingTemplateToTablesheet.gif](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/ApplyingTemplateToTablesheet-20260421.7f8922.gif?width=800)

### Application Behavior

* Templates follow an **apply-only** model.
    Changes made to a template later do not update previously formatted cells.
* Style and Data Validation overwrite existing settings.
* Conditional Formatting and Cell States are appended.

## Creating Custom Templates

You can create a template based on an existing cell configuration.

1. Select a configured cell.
2. Right-click and choose **Create Cell Template…**
3. Enter a name.
4. Select which components to include:
    * Style
    * Conditional Formatting
    * Data Validation
    * Cell States
5. Click OK.

![CreatingCustomTemplates.gif](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/CreatingCustomTemplates-20260421.5398e9.gif?width=800)

### Naming Rules

* The name cannot be empty.
* The name must not duplicate an existing custom template.
* Name comparison is case-insensitive and ignores leading/trailing spaces.
* If multiple cells are selected, only the active cell is used.

The new template appears in the Custom group and is saved with the workbook.

## Managing Templates

Right-click a template in the gallery to manage it.
![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260331.8b0f9e.png?width=300)

### Modify

You can edit the template name (custom templates only) and configure included components.

* **Built-in Templates**
    ![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260331.fa9471.png?width=400)
* **Custom Templates**
    ![image](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/image-20260331.329841.png?width=400)

Changes update the template definition but do not affect cells where it was previously applied.
Built-in templates cannot be renamed. If you need to customize one, duplicate it first.

>type=note
> **Notes:**
>
> * The preview area supports editing sample data to verify template effects with different values. Modified sample data is serialized together with the template definition.
> * Modifications to built-in templates are persisted only after the template is modified or applied. Unmodified built-in templates are restored to their original definitions after refresh or reinitialization.

### Duplicate

* Right-click a template and choose Duplicate.
* A new name is generated automatically (for example, `Template - Copy`).
* If the name already exists, it increments (`Copy (2)`, `Copy (3)`, etc.).

The duplicate is always created as a custom template.
![Duplicate.gif](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/Duplicate-20260421.13f3de.gif?width=800)

### Delete

**Built-in Templates**

* Deletion is local to the current Designer instance.
* Deleted built-in templates are restored after refresh or reinitialization.

**Custom Templates**

* Removed from the workbook.
* If the Custom group becomes empty, it is hidden.
* If the custom template previously overrode a built-in template, the built-in template becomes visible again.

Deleting a template does not remove formatting from cells where it has already been applied.
![Delete.gif](https://cdn.mescius.io/document-site-files/images/b2223940-43c2-44cf-8eda-f5ab9acd84f0/Delete-20260421.7c7ecf.gif?width=800)