Save modified WordprocessingDocument to new file

前端 未结 5 670
礼貌的吻别
礼貌的吻别 2020-11-30 03:48

I\'m attempting to open a Word document, change some text and then save the changes to a new document. I can get the first bit done using the code below but I can\'t figure

5条回答
  •  甜味超标
    2020-11-30 04:25

    Simply copy the source file to the destination and make changes from there.

    File.copy(source,destination);
    using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(destination, true))
        {
           \\Make changes to the document and save it.
           WordDoc.MainDocumentPart.Document.Save();
           WordDoc.Close();
        }
    

    Hope this works.

提交回复
热议问题