翻譯|使用教程|編輯:胡濤|2023-02-27 10:09:42.977|閱讀 165 次
概述:在本文中,您將了解如何使用Spire.Doc for .NET將書簽插入到現(xiàn)有的 Word 文檔中,歡迎查閱
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進(jìn)行操作的 .NET 類庫。在于幫助開發(fā)人員無需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專業(yè)開發(fā)經(jīng)驗(yàn)Spire系列辦公文檔開發(fā)工具,專注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團(tuán)隊(duì)研發(fā),不依賴第三方軟件,不受其他國家的技術(shù)或法律法規(guī)限制,同時適配國產(chǎn)操作系統(tǒng)如中科方德、中標(biāo)麒麟等,兼容國產(chǎn)文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
在處理冗長的 Word 文檔時,插入不同名稱的書簽是標(biāo)記文檔中位置的一種便捷方式。插入書簽后,您可以快速跳轉(zhuǎn)到指定位置,而無需逐頁滾動。在本文中,您將了解如何使用Spire.Doc for .NET將書簽插入到現(xiàn)有的 Word 文檔中。
首先,您需要將包含在 Spire.Doc for .NET 包中的 DLL 文件添加為您的 .NET 項(xiàng)目中的引用。DLL 文件可以從此鏈接下載或通過NuGet安裝。
PM> Install-Package Spire.Doc
Spire.Doc for .NET 提供了Paragraph.AppendBookmarkStart(string name)和Paragraph.AppendBookmarkEnd(string name)方法來將具有指定名稱的書簽插入到 Word 文檔的指定段落中。詳細(xì)步驟如下。
[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 中插入書簽,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請咨詢 ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn