本帖最后由 Richard.Huang 于 2024-2-22 10:24 编辑
您好,您可以通过设置搜索顺序来控制按行还是按列查找:
searchCondition.searchOrder = spreadNS.Search.SearchOrder.nOrder
找到新的符合条件的单元格后,您应该将搜索开始的单元格下移或者右移动一位,否则会出现您描述的一直在当前单元格内:
具体的搜索实现方式可以参考这篇学习指南:https://demo.grapecity.com.cn/sp ... ch/purejs#timestamp
如果您期望实现的是一个全局的搜索,最终结果是一个搜索的结果集,那么您只要按照学习指南中的实现方式做一个递归处理即可,以下是一个示例:
- let searchCondition = new GC.Spread.Sheets.Search.SearchCondition();
- searchCondition.searchString = "testSearch";
- searchCondition.columnStart = 0;
- searchCondition.rowStart = 0;
- let searchResult = sheet.search(searchCondition);
- let str =
- "[searchFoundFlag:" +
- searchResult.searchFoundFlag +
- ",\r\n foundSheetIndex:" +
- searchResult.foundSheetIndex +
- ",foundRowIndex:" +
- searchResult.foundRowIndex +
- ", foundColumnIndex:" +
- searchResult.foundColumnIndex +
- ", foundString:" +
- searchResult.foundSheetIndex +
- "]";
- console.log(str);
- while (
- searchResult.searchFoundFlag != GC.Spread.Sheets.Search.SearchFoundFlags.none
- ) {
- searchCondition.columnStart = searchResult.foundColumnIndex + 1;
- searchCondition.rowStart = searchResult.foundRowIndex;
- searchResult = sheet.search(searchCondition);
- str =
- "[searchFoundFlag:" +
- searchResult.searchFoundFlag +
- ",\r\n foundSheetIndex:" +
- searchResult.foundSheetIndex +
- ",foundRowIndex:" +
- searchResult.foundRowIndex +
- ", foundColumnIndex:" +
- searchResult.foundColumnIndex +
- ", foundString:" +
- searchResult.foundSheetIndex +
- "]";
- console.log(str);
- }
复制代码
|