[英]How to get text out of Word Document using C# open-xml SDK in json like format?
[英]How to split a Word document by section using C# and the Open XML SDK?
我想使用C#和Open XML SDK以编程方式按部分拆分Word文档。 我们已经按段落拆分了Word文档。 现在,我们要对每个部分执行相同的操作。 请任何对此领域有知识的人让我知道以解决此问题。
知道在哪里应用这些部分有点古怪。 不是将段落包装在节中,这使我们易于识别,而是将节应用于在其之前找到的所有内容。
在段落的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
还请记住,最后一个SectionProperties不在段落内,它位于Body标记内的根级别。 不幸的是,据我所知,SDK没有提供用于计算段落所属节的快捷方式。 从这里您应该能够得到一个用于计算截面的快速系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.