C# MIT

SharpDocx

Lightweight template engine for creating Word documents

E

egonl

Dernière activité 24 sept. 2026
egonl/SharpDocx

379

étoiles

83

forks

24

issues ouvertes

docxmicrosoft-wordmvcopen-xml-sdkword

Ce README est souvent en anglais.

SharpDocx

NuGet MIT AppVeyor

Lightweight template engine for creating Word documents

Generating documents with SharpDocx is a two step process. First you create a view in Word. A view is a Word document which also contains C# code. Code can be inserted anywhere, e.g. <%= DateTime.Now %> would insert the current date and time.

The next step is to create documents based on this view. This requires two lines of code:

var document = DocumentFactory.Create("view.cs.docx");
document.Generate("output.docx");

Out of the box SharpDocx supports inserting text, tables, images and more. See the Tutorial sample (here's the view and the controller, and here's the generated document).

If you want, you can specify a view model to be used in your view. Then you could write things like <% foreach (var item in Model.MyList) { %>.

var document = DocumentFactory.Create("view.cs.docx", myModel);
document.Generate("output.docx", myModel);

See also the Model sample.

If you want to do something that's not supported by SharpDocx, you can do so by creating your own document subclass. See the Inheritance example.

SharpDocx supports .NET Framework 3.5-4.8 and .NET Standard 2.0. Since it supports .NET Standard 2.0 it can be used in .NET Core 3.1 and .NET 5.0-11.0 projects as well.

Projets similaires

Fast and easy to use .NET library that creates or modifies Microsoft Word files without installing Word.

C#c-sharpdocxmicrosoft-word
Xxceedsoftware
1,9 k étoiles483

.NET Word(docx) exporting template engine without COM+ & interop (support Linux and Mac)

C#csharpdotnetoffice
Mmini-software
825 étoiles107

Create and modify Word documents with Python

Python
Ppython-openxml
5,7 k étoiles1,3 k