How to set a password to Xltm file

Sheetize XLT M Password Setter for .NET provides a simple yet powerful API for applying password protection to an Excel macro‑enabled template while preserving all worksheets, macros, charts, and formatting. This is useful when you need to secure a template before sharing it or integrating it into pipelines that require encrypted Excel files.

Main Features

Apply Password to XLT M

Encrypt an existing XLT M file with a user‑defined password. The protection covers opening the file and optional restrictions on editing, printing, and structure.

Preserve Formatting & Objects

All cell styles, formulas, tables, charts, macros, and images remain intact after encryption.

Streaming Support

Protect large workbooks in a streaming fashion to keep memory usage low, ideal for batch‑processing of many files.

Detailed Instructions

XLT M Password‑Protection Workflow

To set a password on an XLT M file with Sheetize, follow these steps:

  1. Initialise the Protector: Create an instance of SpreadsheetLocker.
  2. Configure Options: Set LockerSaveOptions with the desired password and protection flags (e.g., allow editing objects, allow printing).
  3. Define File Paths: Provide the source XLT M path and the destination protected XLT M location.
  4. Execute Protection: Call Process with the prepared load and protection options.

Example – Protect an XLT M file with a password

using Sheetize;

var loadOptions = new LoadOptions
{
    InputFile = @"D:\Data\template.xltm"
};

var saveOptions = new LockerSaveOptions
{
    OutputFile = @"D:\Data\protected_template.xltm",
    Password = "MySecretPwd"
};

SpreadsheetLocker.Process(loadOptions, saveOptions);

Example – Protect an XLT M file with a write‑protection password

using Sheetize;

var loadOptions = new LoadOptions
{
    InputFile = @"D:\Data\template.xltm"
};

var saveOptions = new LockerSaveOptions
{
    OutputFile = @"D:\Data\protected_template.xltm",
    PasswordOfWriteProtection = "WritePwd"
};

SpreadsheetLocker.Process(loadOptions, saveOptions);

Expanded Format Support

  • Sheetize can also apply password protection to CSV, TSV, and HTML exports generated from a workbook (the resulting files are wrapped in a ZIP with encryption).

With these capabilities, Sheetize makes XLT M password protection effortless, whether you need a quick one‑off script or a production‑grade service that secures thousands of templates daily.

 Українська