翻譯|使用教程|編輯:胡濤|2022-09-20 10:26:09.113|閱讀 240 次
概述:本文將向您展示如何使用 Spire.Doc for .NET將強調標記應用于 Word 文檔中的文本,歡迎查閱!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spire.Doc for .NET是一款專門對 Word 文檔進行操作的 .NET 類庫。在于幫助開發人員無需安裝 Microsoft Word情況下,輕松快捷高效地創建、編輯、轉換和打印 Microsoft Word 文檔。擁有近10年專業開發經驗Spire系列辦公文檔開發工具,專注于創建、編輯、轉換和打印Word/PDF/Excel等格式文件處理,小巧便捷。下面我們將給您介紹如何在 Word 中應用強調標記。
Word 文檔中使用強調標記來強調單詞并使它們更加引人注目。它通常是放在強調詞上方或下方的一個點或一個圓圈。但是,手動選擇單詞并在其上應用強調標記需要大量工作。幸運的是,用于 .NET 的 Spire.Doc提供了一種更簡單的方法來通過代碼應用強調標記。本文將向您展示如何使用 Spire.Doc for .NET將強調標記應用于 Word 文檔中的文本。
首先,您需要將 Spire.Doc for.NET 包中包含的 DLL 文件添加為 .NET 項目中的引用。DLL 文件可以從此鏈接下載或通過NuGet安裝。
PM> Install-Package Spire.Doc
詳細步驟如下:
【C#】
using System; using Spire.Doc; using Spire.Doc.Documents; namespace applyemphasismark { class Program { static void Main(string[] args) { //Create a Document instance Document document = new Document(); //Load the Word document from disk document.LoadFromFile(@"D:\testp\test.docx"); //Find text you want to emphasize TextSelection[] textSelections = document.FindAllString("Spire.Doc for .NET", false, true); //Apply emphasis mark to the found text foreach (TextSelection selection in textSelections) { selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.Dot; } //Save the document to another Word file string output = "ApllyEmphasisMark.docx"; document.SaveToFile(output, FileFormat.Docx); } } }
【VB.NET】
using System; using Spire.Doc; using Spire.Doc.Documents; namespace applyemphasismark { class Program { static void Main(string[] args) { //Create a Document instance Document document = new Document(); //Load the Word document from disk document.LoadFromFile(@"D:\testp\test.docx"); //Find text you want to emphasize TextSelection[] textSelections = document.FindAllString("Spire.Doc for .NET", false, true); //Apply emphasis mark to the found text foreach (TextSelection selection in textSelections) { selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.Dot; } //Save the document to another Word file string output = "ApllyEmphasisMark.docx"; document.SaveToFile(output, FileFormat.Docx); } } }
以上便是如何在 Word 中應用強調標記(C#/VB.NET),如果您有其他問題也可以繼續瀏覽本系列文章,獲取相關教程,你還可以給我留言或者加入我們的官方技術交流群。
歡迎下載|體驗更多E-iceblue產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn