Sar*_*nan 3 c# openxml openxml-sdk
我想使用C#和Open XML SDK以编程方式分割Word文档.我们已经逐段拆分了Word文档.现在我们想为每个部分执行相同的操作.任何有此领域知识的人请告诉我解决此问题.
小智 8
知道这些部分的应用位置有点古怪.而不是将段落包含在部分中,这使我们很容易识别,而是将部分应用于在他们之前找到的所有内容.
在段落的ParagraphProperties中查找SectionProperties元素,这些元素定义了分节符.找到SectionProperties定义时,最后一个SectionProperties定义与此新定义之间的所有内容将组合在一起作为一个部分.例如,请考虑以下事项:
Paragraph1 // Section 1
Paragraph2 // Section 1
SectionProperties (Section 1) // Defines what section 1 is like
Paragraph3 // Section 2
Paragraph4 // Section 2
SectionProperties (Section 2) // Defines what section 2 is like
Paragraph5 // Section 3
Final SectionProperties // Defines what Section 3 is like.
// This final definition exists within the Body tag itself.
// Other SectionProperties exist under Paragraph Properties
Run Code Online (Sandbox Code Playgroud)
还要记住,最后一个SectionProperties不在段落中,它位于Body标签内的根级别.不幸的是,据我所知,SDK没有提供用于计算段落所属部分的快捷方式.从这里你应该能够得到一个计算部分的快速系统.