【问题标题】:OpenXml - Joining word documents with different footersOpenXml - 加入具有不同页脚的 word 文档
【发布时间】:2012-06-24 10:42:06
【问题描述】:

我正在使用 http://powertools.codeplex.com 和/或 http://docx.codeplex.com 加入 Word 文档。 第一个文档包含页脚,第二个文档没有。 合并后的文档在两个页面/部分都显示页脚。

如何删除第二部分的页脚? 第二节的页脚与前一节相连。 如何使用 OpenXML 2.0 删除此连接?在 Word 中这是没有问题的。

我的源代码可以在这里找到: http://dl.dropbox.com/u/21096596/OpenXML.zip

【问题讨论】:

    标签: ms-word openxml docx


    【解决方案1】:

    我找到了如何替换后续部分的页脚的解决方案:

    MainDocumentPart myPart = document.MainDocumentPart;
    FooterPart newFtPart = myPart.AddNewPart<FooterPart>();
    string ft_ID = myPart.GetIdOfPart(newFtPart);
    
    new DocumentFormat.OpenXml.Wordprocessing.Footer().Save(newFtPart);
    foreach (SectionProperties sectProperties in myPart.Document.Descendants<SectionProperties>().Skip(1))
    {
            FooterReference newFtReference =
             new FooterReference() { Id = ft_ID, Type = HeaderFooterValues.Default };
            sectProperties.Append(newFtReference);
    }
    

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-22
      • 2022-09-23
      • 1970-01-01
      • 2012-06-26
      相关资源
      最近更新 更多