原創(chuàng)|使用教程|編輯:王香|2017-08-31 11:31:03.000|閱讀 758 次
概述:Spire.Doc 是一個(gè)MS Word 組件,使用戶可以直接執(zhí)行各種Word文檔處理任務(wù), 分為.NET、WPF和Silverlight 三個(gè)版本,本文介紹了如何在word文檔中創(chuàng)建書簽。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
NPOI
using NPOI.OpenXmlFormats.Wordprocessing; using NPOI.XWPF.UserModel; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NOPI { class Program { static void Main(string[] args) { //Creat document XWPFDocument doc = new XWPFDocument(); CT_P para = doc.Document.body.AddNewP(); //Bookmark start CT_Bookmark bookmark = new CT_Bookmark(); bookmark.name = "MyBookmak"; para.Items.Add(bookmark); int idCount = para.Items.Count; bookmark.id = idCount.ToString(); para.ItemsElementName.Add(ParagraphItemsChoiceType.bookmarkStart); para.AddNewR().AddNewT().Value = "This is the bookmark"; //Bookmark end bookmark = new CT_Bookmark(); bookmark.id = idCount.ToString(); para.Items.Add(bookmark); para.ItemsElementName.Add(ParagraphItemsChoiceType.bookmarkEnd); //Save the file using (FileStream file = File.Create("Bookmark.docx")) { doc.Write(file); } //Launch System.Diagnostics.Process.Start("Bookmark.docx"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Spire.Doc; using Spire.Doc.Documents; namespace Spire.Doc { class Program { static void Main(string[] args) { //Create document Document doc = new Document(); Section section = doc.AddSection(); Paragraph para=section.AddParagraph(); para.AppendText("This is the bookmark"); //Insert bookmark para.AppendBookmarkStart("MyBookmark"); para.AppendBookmarkEnd("MyBookmark"); //Save and Launch doc.SaveToFile("Bookmark.docx", FileFormat.Docx2013); System.Diagnostics.Process.Start("Bookmark.docx"); } } }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn