本文详细介绍了如何使用 Spire.Doc 和 C# 从 Word 文档中删除段落。
我们使用的示例 word 文档:
Spire.Doc 支持从 word 文档中删除特定段落以及所有段落。本文详细介绍了如何使用 Spire.Doc 和 C# 从 Word 文档中删除段落。
我们使用的示例 word 文档:
删除特定段落
using Spire.Doc;namespace RemoveParagh{class Program{static void Main(string[] args){//Instantiate a Document objectDocument document = new Document();//Load the Word documentdocument.LoadFromFile("Input.docx");//Remove the first paragraph from the first section of the documentdocument.Sections[0].Paragraphs.RemoveAt(0);//Save the documentdocument.SaveToFile("RemoveParagraph.docx", FileFormat.Docx2013);}}}
输出:
删除所有段落
using Spire.Doc;namespace RemoveParagh{class Program{static void Main(string[] args){//Instantiate a Document objectDocument document = new Document();//Load the Word documentdocument.LoadFromFile("Input.docx");//Remove paragraphs from every section in the documentforeach (Section section in document.Sections){section.Paragraphs.Clear();}//Save the documentdocument.SaveToFile("RemoveAllParagraphs.docx", FileFormat.Docx2013);}}}
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询在线客服 ;
标签:
来源:慧都网
声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!