How to Set a Password on an XLSM File

Step‑by‑step guide to using Sheetize for adding a password to XLSM workbooks, keeping them safe and controlling who can open them.


Sheetize XLSM Password Setter for .NET

Sheetize offers a clean, powerful API that lets you apply password protection to an Excel macro‑enabled workbook while leaving every worksheet, macro, chart and formatting untouched. Ideal when you need to secure a file before sharing it or when it has to be fed into a pipeline that only accepts encrypted Excel files.


Key Features

  • Apply a password to an XLSM – Encrypt an existing XLSM with a user‑defined password. Protection covers opening the file and, optionally, restrictions on editing, printing and workbook structure.
  • Preserve formatting & objects – All cell styles, formulas, tables, charts, images and embedded macros stay exactly as they were after encryption.
  • Streaming support – Handles large workbooks in a streaming fashion to keep memory usage low, perfect for batch‑processing dozens or hundreds of files.

Detailed Instructions

XLSM Password‑Protection Workflow

  1. Initialise the protector – Create an instance of SpreadsheetLocker.
  2. Configure the options – Populate a LockerSaveOptions object with the desired password and any protection flags (e.g., allow editing objects, allow printing).
  3. Set the file paths – Provide the source XLSM path and the destination path for the protected file.
  4. Run the protection – Call Process with the load‑ and save‑options.

Example – Protect an XLSM file with a password

using Sheetize;

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

var saveOptions = new LockerSaveOptions
{
    OutputFile = @"D:\Data\protected.xlsm",
    Password = "Test"
};

SpreadsheetLocker.Process(loadOptions, saveOptions);

Example – Protect an XLSM file with a write‑protection password

using Sheetize;

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

var saveOptions = new LockerSaveOptions
{
    OutputFile = @"D:\Data\protected.xlsm",
    PasswordOfWriteProtection = "Test"
};

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 bundled in a ZIP archive that is encrypted).

With these capabilities, Sheetize makes XLSM password protection effortless, whether you need a quick one‑off script or a production‑grade service that secures thousands of spreadsheets every day.

 Українська