长春建设网站公司哪家好,中国建盏品牌形象设计大赛公示,专门做红酒的网站,青岛建设公司网站建设Spire.Doc for .NET是一款专门对 Word 文档进行操作的 .NET 类库。在于帮助开发人员无需安装 Microsoft Word情况下#xff0c;轻松快捷高效地创建、编辑、转换和打印 Microsoft Word 文档。拥有近10年专业开发经验Spire系列办公文档开发工具#xff0c;专注于创建、编辑、转…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 最新下载qun767755948https://www.evget.com/product/3368/download
在处理冗长的 Word 文档时插入不同名称的书签是标记文档中位置的一种便捷方式。插入书签后您可以快速跳转到指定位置而无需逐页滚动。在本文中您将了解如何使用Spire.Doc for .NET将书签插入到现有的 Word 文档中。
安装适用于 .NET 的 Spire.Doc
首先您需要将包含在 Spire.Doc for .NET 包中的 DLL 文件添加为您的 .NET 项目中的引用。DLL 文件可以从此链接下载或通过NuGet安装。 PM Install-Package Spire.Doc将书签插入现有 Word 文档
Spire.Doc for .NET 提供了Paragraph.AppendBookmarkStart(string name)和Paragraph.AppendBookmarkEnd(string name)方法来将具有指定名称的书签插入到 Word 文档的指定段落中。详细步骤如下。
创建一个文档实例。使用Document.LoadFromFile()方法加载示例 Word 文档。使用Document.Sections[]属性获取 Word 文档的第一部分。使用Section.Paragraphs[]属性获取该部分的指定段落。使用Paragraph.AppendBookmarkStart( string name ) 方法将具有指定名称的书签的开头追加到指定段落。使用Paragraph.AppendBookmarkEnd( string name ) 方法将具有指定名称的书签结尾附加到指定段落。使用文档将文档保存到另一个文件。保存到文件()方法。
[C] using Spire.Doc;namespace WordBookmark
{
class Bookmark
{
static void Main(string[] args)
{
//Create a Document instance
Document document new Document();//Load a sample Word document
document.LoadFromFile(C:\Users\Administrator\Desktop\test.docx);//Get the first section
Section section document.Sections[0];//Insert a bookmark with specified name into the specified paragraphs
section.Paragraphs[9].AppendBookmarkStart(SecurityTerm);
section.Paragraphs[11].AppendBookmarkEnd(SecurityTerm);//Save the document to file
document.SaveToFile(Bookmark.docx, FileFormat.Docx);
}
}
}[VB.NET] using Spire.Doc;namespace WordBookmark
{
class Bookmark
{
static void Main(string[] args)
{
//Create a Document instance
Document document new Document();//Load a sample Word document
document.LoadFromFile(C:\Users\Administrator\Desktop\test.docx);//Get the first section
Section section document.Sections[0];//Insert a bookmark with specified name into the specified paragraphs
section.Paragraphs[9].AppendBookmarkStart(SecurityTerm);
section.Paragraphs[11].AppendBookmarkEnd(SecurityTerm);//Save the document to file
document.SaveToFile(Bookmark.docx, FileFormat.Docx);
}
}
} 以上便是如何C#/VB.NET在 Word 中插入书签如果您有其他问题也可以继续浏览本系列文章获取相关教程你还可以给我留言或者加入我们的官方技术交流群。