跳到主要内容

Search

在表格对象的范围内搜索。搜索结果是 ApiRange 对象的集合。

语法

expression.Search(sText, isMatchCase);

expression - 表示 ApiTable 类的变量。

参数

名称必需/可选数据类型默认值描述
sText必需string搜索字符串。
isMatchCase必需boolean是否区分大小写。

返回值

ApiRange[]

示例

此示例展示如何在表格中进行搜索。

// How to search throughout the table.

// Get a table, search information using value, position, order, etc.

let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
table.GetCell(0, 0).GetContent().GetElement(0).AddText("Cell 1");
table.GetCell(0, 1).GetContent().GetElement(0).AddText("Cell 2");
table.GetCell(0, 2).GetContent().GetElement(0).AddText("Cell 3");
doc.Push(table);
let searchResults = table.Search("Cell");
searchResults[0].SetBold(true);