Skip to content

chaowlert/WordReport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordReport

Generate report from Word document. Not required MS Office to generate documents.

NuGet

Get it

PM> Install-Package WordReport

Step 1: Provide word template file

NOTE: template is Scriban, please see usage there.
NOTE2: You need to open selection pane to get or set image name to replace

image

Step 2: Provide data models & images (optional)

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")
};

Step 3: Load template (NOTE: you can reuse template to generate multiple output)

var reporter = WordTemplate.FromFile("Template.docx");

Step 4: Generate output

var mem = new MemoryStream();
reporter.Render(mem, data, images);
File.WriteAllBytes("Output.docx", mem.ToArray());

image

About

Generate report from Word document

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages