如何删除word文本中空白的行
请尝试使用以下代码:
Document doc = new Document("E:\\temp\\emptyparagraph.docx");
Node[] paras = doc.GetChildNodes(NodeType.Paragraph, true).ToArray();
foreach (Paragraph p in paras)
if (string.IsNullOrEmpty(p.ToString(SaveFormat.Text).Trim()))
p.Remove();
doc.Save("E:\\Temp\\19.8.docx");
希望这可以帮助。