简体   繁体   中英

Update word to newest format with open xml

I have an application that download docx file from a service. The problem is that the service creates the docx with the an old format (I think it used the open xml version 2.0). I don't own the service so I can't change the creation process of the word , but I thought about building a convertor , that will open the downloaded files and recreate them in the newest format using the open xml sdk version 2.5. I was optimistic when I thought this code will work ( A simple open and save) :

WordprocessingDocument  wordprocessingDocument =
                         WordprocessingDocument.Open(filePath, true);
 wordprocessingDocument.MainDocumentPart.Document.Save();

I'm not fimiliar with the open xml sdk , so any help will be appreciated.

You're just opening the doc and saving it with no changes. You need to change the Word version, then save it. This article should provide the info you need: http://blogs.msmvps.com/wordmeister/2013/01/18/openxmlsdk-word-compatibility-mode/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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