1
我想在将内容解析为xml之前从.docx文件中删除空的段落。我将如何实现这一目标?使用OpenXML SDK 2.0从.docx中删除空的段落
Protected Sub removeEmptyParagraphs(ByRef body As DocumentFormat.OpenXml.Wordprocessing.Body)
Dim colP As IEnumerable(Of Paragraph) = body.Descendants(Of Paragraph)()
Dim count As Integer = colP.Count
For Each p As Paragraph In colP
If (p.InnerText.Trim() = String.Empty) Then
body.RemoveChild(Of Paragraph)(p)
End If
Next
End Sub