English 中文(简体)
负责人/警校的命令 开放XML文件部分
原标题:Order of Header/FooterParts in OpenXML document

我需要从开放式XML文件中取回标题/碎片部分,以便列入文件。

The following:-

foreach (HeaderPart header in document.MainDocumentPart.HeaderParts)
{
  ...
}

- 通过<代码>HeaderParts向散射线照射,无一例外。

谁能解释如何正确下令执行? 无论是通过使用指令By,还是通过使用<代码>HeaderParts的方式?

<>Edit>: 实例

例如:-

例如,我有几节休息。 每个科都有不同的主人/脚人:

  • Section 1 => Section 1 Footer
  • Section 2 => Section 2 Footer
  • Section 3 => Section 3 Footer
  • Section 4 => Section 4 Footer

文件中没有“不同的第一页”或“不同的奇/偶”标题或脚本。

当我试图利用<条码>文件复制这些脚本时,他们没有出现在第1、2、3、4号命令中,我无法确定这些脚步按顺序排列的逻辑。 我怀疑他们没有被命令。

我需要这样做。

最佳回答

您实际上不想首先拿到头部/脚部,希望按照文件.xml的顺序将其带进去,然后取回零部件。 为此,你需要像林克这样的东西来询问主要文件。 之后,你可以找到自己的关系身份证,从那里使用包装来获取实际内容。 但是,从一开始,你就象这样需要去做:

Imports System.Linq
Imports <xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">

Module Module1
    Sub Main()
        Dim doc As String = "C:headers.docx"
        Dim wordDoc = WordprocessingDocument.Open(doc, False)
        Using wordDoc
            Dim mainPart = wordDoc.MainDocumentPart
            Dim docStream As System.IO.StreamReader = New IO.StreamReader(mainPart.GetStream)
            Dim xDoc As XElement = XElement.Load(docStream)
            Dim sectionHeaders = From e In xDoc...<w:sectPr> Select e.<w:headerReference>
        End Using
    End Sub

End Module

生活状况 NET——我不知道C#。 但这一概念是相同的。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签