Generate report from Word document. Not required MS Office to generate documents.
PM> Install-Package WordReport
NOTE: template is Scriban, please see usage there.
NOTE2: You need to open selection pane to get or set image name to replace
var data = new
{
teacher = "Ben",
author = "John Doe",
students = new[]
{
new {name = "Foo", age = 15},
new {name = "Bar", age = 16},
}
};
var images = new Dictionary<string, byte[]>
{
["signature_pic"] = File.ReadAllBytes("signature.png")
};
var reporter = WordTemplate.FromFile("Template.docx");
var mem = new MemoryStream();
reporter.Render(mem, data, images);
File.WriteAllBytes("Output.docx", mem.ToArray());