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