翻譯|使用教程|編輯:胡濤|2022-09-20 10:26:09.113|閱讀 240 次
概述:本文將向您展示如何使用 Spire.Doc for .NET將強(qiáng)調(diào)標(biāo)記應(yīng)用于 Word 文檔中的文本,歡迎查閱!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
Spire.Doc for .NET是一款專(zhuān)門(mén)對(duì) Word 文檔進(jìn)行操作的 .NET 類(lèi)庫(kù)。在于幫助開(kāi)發(fā)人員無(wú)需安裝 Microsoft Word情況下,輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔。擁有近10年專(zhuān)業(yè)開(kāi)發(fā)經(jīng)驗(yàn)Spire系列辦公文檔開(kāi)發(fā)工具,專(zhuān)注于創(chuàng)建、編輯、轉(zhuǎn)換和打印Word/PDF/Excel等格式文件處理,小巧便捷。下面我們將給您介紹如何在 Word 中應(yīng)用強(qiáng)調(diào)標(biāo)記。
Word 文檔中使用強(qiáng)調(diào)標(biāo)記來(lái)強(qiáng)調(diào)單詞并使它們更加引人注目。它通常是放在強(qiáng)調(diào)詞上方或下方的一個(gè)點(diǎn)或一個(gè)圓圈。但是,手動(dòng)選擇單詞并在其上應(yīng)用強(qiáng)調(diào)標(biāo)記需要大量工作。幸運(yùn)的是,用于 .NET 的 Spire.Doc提供了一種更簡(jiǎn)單的方法來(lái)通過(guò)代碼應(yīng)用強(qiáng)調(diào)標(biāo)記。本文將向您展示如何使用 Spire.Doc for .NET將強(qiáng)調(diào)標(biāo)記應(yīng)用于 Word 文檔中的文本。
首先,您需要將 Spire.Doc for.NET 包中包含的 DLL 文件添加為 .NET 項(xiàng)目中的引用。DLL 文件可以從此鏈接下載或通過(guò)NuGet安裝。
PM> Install-Package Spire.Doc
詳細(xì)步驟如下:
【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 中應(yīng)用強(qiáng)調(diào)標(biāo)記(C#/VB.NET),如果您有其他問(wèn)題也可以繼續(xù)瀏覽本系列文章,獲取相關(guān)教程,你還可以給我留言或者加入我們的官方技術(shù)交流群。
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請(qǐng)咨詢(xún) ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn