OpenXML无法打开文件,Word打开就好了 [英] OpenXML can't open a file, Word opens it just fine
问题描述
请查看
http://www.windwardreports.com/中的文件。 temp / InvalidPackage.zip
它有一个有效的document.xml,Word可以正常打开文件。但是OpenXML SDK引发了一个异常:
It has a valid document.xml and Word opens the file fine. But the OpenXML SDK throws an exception:
发生了DocumentFormat.OpenXml.Packaging.OpenXmlPackageException
Message ="指定的包无效。缺少主要部分。"
Source =" DocumentFormat.OpenXml"
StackTrace:
在DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load()
在DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(Stream stream,Boolean readWriteMode)
在DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(Stream stream,Boolean isEditable,OpenSettings openSettings)
在DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(Stream stream,Boolean isEditable)
DocumentFormat.OpenXml.Packaging.OpenXmlPackageException occurred
Message="The specified package is invalid. The main part is missing."
Source="DocumentFormat.OpenXml"
StackTrace:
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Load()
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.OpenCore(Stream stream, Boolean readWriteMode)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(Stream stream, Boolean isEditable, OpenSettings openSettings)
at DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(Stream stream, Boolean isEditable)
知道为什么吗?
谢谢 - 戴夫
推荐答案
嗨Dave,
感谢您的提问。
我试图打开您的共享文档,发现在"w:document"之前有一行评论。这就是错误消息显示"主要部分缺失"的原因。您可以删除评论,然后一切正常。
I tried to open your shared document and found that there is a line of comment before the "w:document". That's why the error message shows "The main part is missing." You could remove the comment and then everything works well.
BTW,我想知道如何生成此文档,因为在Word中打开它时,我发现它在"兼容性"中模式" ;.我想知道它是否严格基于 Open XML Format。它起源于".doc"吗?文件?
BTW, I want to know how do you generate this document, for when opening it in Word, I find it is in "Compatibility Mode". I wonder if it is not strictly based on Open XML Format. Is it originated from a ".doc" file?
希望这有帮助。如果您有任何疑问,请告诉我。
Hope this helps. If you have any question, please let me know.
谢谢,
Lu
这篇关于OpenXML无法打开文件,Word打开就好了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!