DocXReplacements() публичный Метод

public DocXReplacements ( Person p ) : DocX
p Person
Результат DocX
Пример #1
0
 public override void ExecuteResult(ControllerContext context)
 {
     var wc = new WebClient();
     var bytes = wc.DownloadData(template);
     var ms = new MemoryStream(bytes);
     var doctemplate = DocX.Load(ms);
     var replacements = new EmailReplacements(DbUtil.Db, doctemplate);
     var q = peopleId.HasValue
         ? DbUtil.Db.PeopleQuery2(peopleId)
         : DbUtil.Db.PeopleQuery(guid);
     if (!q.Any())
         throw new Exception("no people in query");
     var finaldoc = replacements.DocXReplacements(q.First());
     foreach (var p in q.Skip(1))
     {
         finaldoc.InsertParagraph().InsertPageBreakAfterSelf();
         var doc = replacements.DocXReplacements(p);
         finaldoc.InsertDocument(doc);
     }
     context.HttpContext.Response.Clear();
     context.HttpContext.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
     context.HttpContext.Response.AddHeader("Content-Disposition", $"attachment;filename={filename}-{DateTime.Now.ToSortableDateTime()}.docx");
     finaldoc.SaveAs(context.HttpContext.Response.OutputStream);
 }