原副标题:.NET Word模板发动机–MiniWord,继MiniExcel后又一开放源码经典作品!
Part1简介
MiniWord 是.NET Word模板发动机,由Word模板和统计数据,单纯、加速聚合文档。
Part2特征
.NET Word(docx) 模板求出发动机不须要加装 Office COM+
全力支持 Linux 和 Mac
全力支持聚合文档、相片、条目、表单
Part3 加装nuget link : https://www.nuget.org/packages/MiniWord
.NET CLI : dotnet add package MiniWord –version 0.4.0
Part4 采用MiniWord 采用类似于 Vue, React 的模板字符串 {{tag}},只须要保证 tag 与 value 模块的 key 那样(UTF脆弱),控制系统会手动代替字符串。
文档聚合
模板
标识符
条码值string类型
string templatePath = @“E:\02_blibli\wenz\43_MiNiword\Template\Test.docx”;
string outputPath = @ “E:\02_blibli\wenz\43_MiNiword\OutPut\TestOutPut.docx”;
var value = new Dictionary<string, object> {
[ “title”] = “Hello MiniWord”,
};
MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
聚合
相片聚合
模板
标识符
条码值 MiniWordPicture 类型
string templatePath = @ “E:\02_blibli\wenz\43_MiNiword\Template\Test.docx”;
string outputPath = @ “E:\02_blibli\wenz\43_MiNiword\OutPut\TestOutPut.docx”;
var value = new Dictionary<string, object> {
[ “logo”] = new MiniWordPicture{ Path = @ “E:\02_blibli\wenz\43_MiNiword\Template\logo.jpg”, Width = 180, Height = 180 },
};
MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
聚合
条目聚合
模板
标识符
条码值 string[] 或是 IList 类型
string templatePath = @ “E:\02_blibli\wenz\43_MiNiword\Template\Test.docx”;
string outputPath = @ “E:\02_blibli\wenz\43_MiNiword\OutPut\TestOutPut.docx”;
var value = new Dictionary<string, object> {
[ “list”]=new string[] { “1”, “2”, “3”},
};
MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
聚合
表单聚合
模板
标识符 条码值 IEmerable<Dictionary<string,object>>类型
string templatePath = @ “E:\02_blibli\wenz\43_MiNiword\Template\Test.docx”;string outputPath = @“E:\02_blibli\wenz\43_MiNiword\OutPut\TestOutPut.docx”;
var value = new Dictionary<string, object> {
[ “person”] = new List<Dictionary<string, object>> {
new Dictionary<string, object>{{ “name”, “Wade”},{ “age”, “HR”} },
new Dictionary<string, object> {{ “name”, “Felix”},{ “age”, “HR”} },
new Dictionary<string, object>{{“name”, “Eric”},{ “age”, “IT”} },
new Dictionary<string, object> {{ “name”, “Keaton”},{ “age”, “IT”} }
}
};
MiniSoftware.MiniWord.SaveAsByTemplate(outputPath, templatePath, value);
聚合
Part5总结
目前来说MiniWord功能还比较少,达不到商用的程度,但是我相信 在不久的将来,MiniWord会越来越好! 如果对MiniWord感兴趣的可以去Gitee或者Github点个Star。
gitee:https://gitee.com/dotnetchina/MiniWord
github:https://github.com/mini-software/MiniWord/