我成功实现了OpenXML,它在文档中取代了书签并替换它们。不幸的是,它只适用于.docx,我理解的.doc与OpenXML格式不兼容。

所以,我想知道什么是,如果我可以在用户尝试下载时将其转换为.doc。那可能吗?如果有人知道如何做到这一点?

有帮助吗?

解决方案

从docx转换为doc与打开的xml sdk 2.0是不可能的。

其他提示

要么使用第三方库,如aspes.words。或者您需要使用Microsoft Interop Services。

这是样本c#代码:

Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document wordDocument = wordApplication.Documents.Open(opath);
wordDocument.SaveAs("BLUH.DOC",  WdSaveFormat.wdFormatDocument);

((Microsoft.Office.Interop.Word._Document)wordDocument).Close(); // cast necessary
((Microsoft.Office.Interop.Word._Application)wordApplication).Quit(); // cast necessary
.

看看这些页面:

fileconverter

saveformat

SaveAs

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top