我对此有问题:
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true)) { }
Run Code Online (Sandbox Code Playgroud)
使用上面的方法并尝试在 Word 中打开文档,显示文件已损坏的错误消息。有趣的是,对于 LibreOffice 文件来说是可以的。我在使用此代码之前和之后比较了 WinMarge 文件中的 xml 文件(在 docx 中),两者是相同的。差异仅在于 docx 文件的大小 - 为什么?
好的..我解决了问题..这不是一个很好的解决方案,但它有效..
var document = "template.docx";
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true))
{
// some editing stuff
wordDoc.Clone("ready.docx");
}
Run Code Online (Sandbox Code Playgroud)
现在template.docx
已损坏,但ready.docx
还好。
归档时间: |
|
查看次数: |
2975 次 |
最近记录: |