我正在尝试阅读Word 2007 docx文档。
在Word中查看文档时,一切正常,但是当我尝试使用代码阅读它时,所有的Run对象的RunProperites都设置为null。
我最感兴趣的属性是RunProperies.FontSize,但不幸的是它也是null,我能够访问的唯一属性是InnerText。
我的代码如下:
using (WordprocessingDocument doc = WordprocessingDocument.Open(filename, true))
{
MainDocumentPart mainPart = doc.MainDocumentPart;
IList<Paragraph> paragraphList = doc.MainDocumentPart.Document.Body.Elements<Paragraph>().ToList<Paragraph>();
foreach (Paragraph pr in paragraphList)
{
IList<Run> runList = pr.Elements<Run>().ToList<Run>();
foreach (Run r in runList)
{
// Some logic
}
}
}
我已经将文档最简化,它看起来像这样http://dl.dropbox.com/u/204110/test.docx。
我有类似的文档可以正常阅读。OpenXML SDK 2中可能存在错误吗?
有人遇到过类似问题吗?任何帮助都将不胜感激。 谢谢!