文档半岛外围网上直营>>E-iceblue中文文档>>从 Word 文档中删除段落
从 Word 文档中删除段落
Spire.Doc for .NET是一款专门对 Word 文档进行操作的 .NET 类库。在于帮助开发人员无需安装 Microsoft Word情况下,轻松快捷高效地创建、编辑、转换和打印 Microsoft Word 文档。拥有近10年专业开发经验Spire系列办公文档开发工具,专注于创建、编辑、转换和打印Word/PDF/Excel等格式文件处理,小巧便捷。
E-iceblue 功能类库Spire 系列文档处理组件均由中国本土团队研发,不依赖第三方软件,不受其他国家的技术或法律法规限制,同时适配国产操作系统如中科方德、中标麒麟等,兼容国产文档处理软件 WPS(如 .wps/.et/.dps 等格式
Spire.Doc for.NET 最新下载
技术交流Q群(767755948)
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产品

QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线