using (WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(filepath, true)) { // ... }
private void CreateWordprocessingDocument(string filepath) { using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document)) { MainDocumentPart mainPart = wordDocument.AddMainDocumentPart(); mainPart.Document = new Document(); Body body = mainPart.Document.AppendChild(new Body()); Paragraph para = body.AppendChild(new Paragraph()); Run run = para.AppendChild(new Run()); foreach (string s in _myList) { run.AppendChild(new Text(s)); run.AppendChild(new Paragraph()); // ImagePart ip = wordDocument.MainDocumentPart.AddImagePart(ImagePartType.Jpeg); // using (FileStream fs = new FileStream(file, FileMode.Open)) // { // ip.FeedData(fs); // } run.AppendChild(new Break() { Type = BreakValues.Page }); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)