Tab 1
此 Demo 展示如何在 Word 文档中搜索文本并高亮显示匹配的文本。
Upload
Maximum file size: 1 MB. Files accepted: doc, docx, txt, rtf.

fileerrors
Convert to
Source file:
filename
Search Text:
如果这不是您想要的 Demo,您可以通过填写表格获取免费定制 Demo。
如您有与我们产品相关的其他技术问题,请联系 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。;销售相关的问题,请联系 该Email地址已收到反垃圾邮件插件保护。要显示它您需要在浏览器中启用JavaScript。。
Tab 2
using System;using System.Drawing;using Spire.Doc;using Spire.Doc.Documents;using Spire.Doc.Fields;namespace DemoOnlineCode{class FindAndHighlight{public void demoFindAndHighlight(String docFile,String searchText){Document document = new Document(docFile,FileFormat.Auto);TextSelection[] textSelections = document.FindAllString(searchText,false,false);if (textSelections != null){foreach (TextSelection selection in textSelections){TextRange textMatched = selection.GetAsOneRange();textMatched.CharacterFormat.HighlightColor = Color.Yellow;}}document.SaveToFile("demo.doc",FileFormat.Doc);}}}
Tab 3
Imports System.Drawing Imports Spire.Doc Imports Spire.Doc.Documents Imports Spire.Doc.Fields Namespace DemoOnlineCode Class FindAndHighlight Public Sub demoFindAndHighlight(docFile As [String],searchText As [String]) Dim document As New Document(docFile,FileFormat.Auto) Dim textSelections As TextSelection() = document.FindAllString(searchText,False,False) If textSelections IsNot Nothing Then For Each selection As TextSelection In textSelections Dim textMatched As TextRange = selection.GetAsOneRange() textMatched.CharacterFormat.HighlightColor = Color.Yellow Next End If document.SaveToFile("demo.doc",FileFormat.Doc) End Sub End Class End Namespace