简体   繁体   English

如何在Visual Studio中使用openxml覆盖.docx文件?

[英]How to overwrite a .docx file using openxml in visual studio?

I have created a word file using openxml in visualstudio. 我已经在visualstudio中使用openxml创建了一个Word文件。 But I want to overwrite the file. 但是我想覆盖文件。 How should I proceed? 我应该如何进行?

Your question is not really clear to me. 您的问题对我来说不是很清楚。 So I decided to give you a starting point: 所以我决定给你一个起点:

public void YourAwesomeMethod()
{
       WordprocessingDocument wordDocument = WordprocessingDocument.Create("path", WordprocessingDocumentType.Document);

       // do all the crazy stuff with your document...

       wordDocument.MainDocumentPart.Document.Save(); // save it!
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM