Skip to content

Save as template(.xltx, .xltm)

karlkallman edited this page Aug 6, 2026 · 1 revision

Save as template(.xltx, .xltm)

EPPlus can save packages as an Excel template instead of an standard workbook.

What is an Excel Template?

An excel template(.xltx) is a template for new workbooks. When opening the template workbook, Excel creates a new copied workbook from the template while the original .xltx file remains unchanged.

Saving as template

Lets show an example. Set the SaveAsTemplate property on the package

using (var package = new ExcelPackage())
{
    package.SaveAsTemplate = true;
    package.SaveAs(new FileInfo(@"c:\workbooks\InvoiceTemplate.xltx"));
}

Or supply it through the save options:

package.SaveAs(new FileInfo(@"c:\workbooks\InvoiceTemplate.xltx"), o => o.SaveAsTemplate = true);

The options overload is available on Save, SaveAs (file path, FileInfo and Stream) and their async equivalents.

Loading a template

SaveAsTemplate is false by default, also when the loaded file is a template. Loading an .xltx and saving it again therefore produces a standard workbook, which mirrors how Excel handles templates. Set SaveAsTemplate to true if you want to keep the template format:

using (var package = new ExcelPackage(new FileInfo(@"c:\temp\InvoiceTemplate.xltx")))
{
    package.SaveAsTemplate = true;   // keep it a template
    package.Save();
}

Note on file extensions

SaveAsTemplate controls the content type inside the package; the file name is up to you. Use a matching extension (.xltx / .xltm) so that Excel and other tools handle the file as expected.

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally