William.DocxTemplateEngine
1.0.1
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package William.DocxTemplateEngine --version 1.0.1
NuGet\Install-Package William.DocxTemplateEngine -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="William.DocxTemplateEngine" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="William.DocxTemplateEngine" Version="1.0.1" />
<PackageReference Include="William.DocxTemplateEngine" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add William.DocxTemplateEngine --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: William.DocxTemplateEngine, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package William.DocxTemplateEngine@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=William.DocxTemplateEngine&version=1.0.1
#tool nuget:?package=William.DocxTemplateEngine&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
William.DocxTemplateEngine
Lightweight DOCX template engine for .NET using TemplateEngine.Docx.
π¦ Installation
dotnet add package William.DocxTemplateEngine
π Quick Start
var engine = new DocxTemplateEngine();
engine.Render(
"template.docx",
"output.docx",
new
{
contract_number = "HD001",
staffs = new[]
{
new
{
role = "Kα»Ή thuαΊt",
staff_email_vietunion = "tech@abc.com",
staff_phone_vietunion = "0909000001",
staff_email_partner = "tech@abc.com",
staff_phone_partner = "0909000001"
},
new
{
role = "CSKH",
staff_email_vietunion = "cs@abc.com",
staff_phone_vietunion = "0909000002",
staff_email_partner = "tech@abc.com",
staff_phone_partner = "0909000001"
}
}
}
);
Render to byte[]
var bytes = engine.RenderToBytes("template.docx", model);
Render from Stream
using var stream = File.OpenRead("template.docx");
var bytes = engine.RenderToBytes(stream, model);
βοΈ Options
engine.Render("template.docx", "output.docx", model, removeContentControls: true);
| Parameter | Description |
|---|---|
| removeContentControls | Remove content controls after rendering (default: true) |
π Creating Template (Content Controls)
This library uses Word Content Controls, not plain text placeholders.
Enable Developer Tab
- Open Microsoft Word
- Go to File β Options β Customize Ribbon
- Enable Developer
Create a simple field
- Go to Developer
- Click Plain Text Content Control
- Open Properties
- Set:
Tag: contract_number
Create a table (repeating data)
- Insert a table in Word
- In the data row, add Content Controls for each column
Example tags:
- role
- staff_email_vietunion
- staff_phone_vietunion
- staff_email_partner
- staff_phone_partner
Repeating Section (Important)
To bind a collection:
- Select the entire data row
- Click Repeating Section Content Control
- Set:
Tag: staffs
Official Documentation
https://learn.microsoft.com/en-us/office/client-developer/word/content-controls-in-word
π Notes
- Template must use Content Controls
- Field names must match model properties
- Do not use {{variable}} syntax
π License
MIT License Β© 2026 William
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- TemplateEngine.Docx (>= 1.1.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|