来源:蜘蛛抓取(WebSpider)
时间:2023-11-16 21:00
标签:
word首行缩进2字符
248 篇文章
25 订阅订阅专栏Spire.Doc 支持从 word 文档中删除特定段落以及所有段落。本文详细介绍了如何使用 Spire.Doc 和 C# 从 Word 文档中删除段落。我们使用的示例 word 文档:Spire.Doc for.NET 最新下载(qun:767755948)https://www.evget.com/product/3368/download删除特定段落
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);
}
}
}
分类专栏
您愿意向朋友推荐“博客详情页”吗?
强烈不推荐
不推荐
一般般
推荐
强烈推荐