tab 1
此 demo 展示如何在 word 文档中搜索文本并高亮显示匹配的文本。
如果这不是您想要的 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