How to get all merge fields of word document using open xml sdk

旧街凉风 提交于 2019-12-05 10:24:33

You have to loop through header and footer separately, see the following code:

foreach (var header in doc.MainDocumentPart.HeaderParts)
            foreach (var cc in header.RootElement.Descendants<FieldCode>())
                //DO CODE
foreach (var footer in doc.MainDocumentPart.FooterParts)
           foreach (var cc in footer.RootElement.Descendants<FieldCode>())
                //DO CODE
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!