找回密码
 立即注册

QQ登录

只需一步,快速开始

zzzfff
金牌服务用户   /  发表于:2023-3-30 10:34  /   查看:1313  /  回复:1
  1. const wb = workbook;
  2. const sheets = wb.sheets;
  3. let currentSheetIdx = 0;
  4. const res = [];

  5. const searchCondition = new GC.Spread.Sheets.Search.SearchCondition();
  6. searchCondition.searchString = 16;
  7. searchCondition.searchFlags=GC.Spread.Sheets.Search.SearchFlags.ignoreCase | GC.Spread.Sheets.Search.SearchFlags.useWildCards;
  8. searchCondition.searchTarget = GC.Spread.Sheets.Search.SearchFoundFlags.cellText;
  9. while (currentSheetIdx < sheets.length) {
  10.    const searchResult = wb.search(searchCondition);
  11.    if (
  12.      !searchResult ||
  13.      searchResult.searchFoundFlag === GC.Spread.Sheets.Search.SearchFoundFlags.none
  14.    ) {
  15.      searchCondition.columnStart = 0;
  16.      searchCondition.rowStart = 0;
  17.      searchCondition.startSheetIndex = currentSheetIdx + 1;
  18.      currentSheetIdx += 1;
  19.    } else {
  20.      res.push(searchResult);
  21.    
  22.      searchCondition.columnStart = searchResult.foundColumnIndex + 1;
  23.      searchCondition.rowStart = searchResult.foundRowIndex;
  24.      currentSheetIdx = searchResult.foundSheetIndex;
  25.    }
  26. }
  27. console.log(res)
复制代码
以上是参考demo写的搜索,使用附件的sheet5的数据是sheet2、sheet3的并集,搜索比如16,sheet2,sheet3的数据搜索不出来,但是sheet5的数据能搜索

搜索葡萄城反馈示例.xlsx

16.06 KB, 下载次数: 22

1 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2023-3-30 18:00:20
沙发
本帖最后由 Richard.Ma 于 2023-4-3 16:43 编辑

仔细看了一下你的代码,其中和这个示例中不同的地方较多,如果你要循环查找,建议可以直接使用学习指南中的示例代码
不管是整个workbook查询还是单个sheet查询,测试都是没有问题的(在这个示例中导入了你的xlsx转的workbook json对象)

https://demo.grapecity.com.cn/sp ... ok/search#timestamp
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部