翻譯|使用教程|編輯:胡濤|2022-06-01 10:40:57.670|閱讀 63 次
概述:本文詳細介紹了如何使用 Spire.Doc 和 C# 從 Word 文檔中刪除段落。 我們使用的示例 word 文檔:
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spire.Doc 支持從 word 文檔中刪除特定段落以及所有段落。本文詳細介紹了如何使用 Spire.Doc 和 C# 從 Word 文檔中刪除段落。
我們使用的示例 word 文檔:
刪除特定段落
using Spire.Doc; namespace RemoveParagh { class Program { static void Main(string[] args) { //Instantiate a Document object Document document = new Document(); //Load the Word document document.LoadFromFile("Input.docx"); //Remove the first paragraph from the first section of the document document.Sections[0].Paragraphs.RemoveAt(0); //Save the document document.SaveToFile("RemoveParagraph.docx", FileFormat.Docx2013); } } }
輸出:
刪除所有段落
using Spire.Doc; namespace RemoveParagh { class Program { static void Main(string[] args) { //Instantiate a Document object Document document = new Document(); //Load the Word document document.LoadFromFile("Input.docx"); //Remove paragraphs from every section in the document foreach (Section section in document.Sections) { section.Paragraphs.Clear(); } //Save the document document.SaveToFile("RemoveAllParagraphs.docx", FileFormat.Docx2013); } } }
歡迎下載|體驗更多E-iceblue產(chǎn)品
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn