SharpDocx
Lightweight template engine for creating Word documents
Install / Use
/learn @egonl/SharpDocxREADME
SharpDocx
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, .NET 5.0 and .NET 6.0 projects as well.
Related Skills
node-connect
349.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.7kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
