Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 1.58 KB

README.md

File metadata and controls

45 lines (36 loc) · 1.58 KB

PowerPointTool NuGet version

PowerPoint presentation from template and model

Example #1 - Create from template

var ppTool = new PPTool();
var template = File.ReadAllBytes(@".\template.pptx");
var result = ppTool.CreateFromTemplate(template, ctx => new {
  Title = "Example",
  Created = DateTimeOffset.Now,
  User = new { 
    Name = "TestName", 
    IsActive = true,
    Evaluation = 1000000,
  },
  Items = Enumerable.Range(1, 5).Select(x => $"item#{x}"),
});

Example #2 - Iterator for slides/rows

var result = ppTool.CreateFromTemplate(template, ctx => 
  Enumerable.Range(1, 3).Select(x => new {
    CompanyName = $"Company #{x}",
    Employees = Enumerable.Range(1, _rnd.Next(4, 12)).Select(xx => new {
        Name = $"Employee #{xx}",
        Email = $"emp{xx}@company{x}.test",
        Birthday = new DateTime(_rnd.Next(1980, 2000), _rnd.Next(1, 12), 1).AddDays(_rnd.Next(0, 30)),
    }),
  })
);

Presentations: template.pptx , result.pptx

Program.cs