Google Apps脚本TextFinder startFrom不是从 [英] Google Apps Script TextFinder startFrom not starting from

查看:69
本文介绍了Google Apps脚本TextFinder startFrom不是从的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用TextFinder,但是在电子表格中,我不想在结果中返回标题行或列1.我看到TextFinder有一个"startFrom"方法,该方法应该让您定义应从其开始搜索的单元格范围"……但我似乎无法使其工作.

I'm trying to use TextFinder, but in my spreadsheet, I don't want to return the header row or column 1 in my results. I see that TextFinder has a "startFrom" method that's supposed to let you define "The cell range after which the search should start" ... but I can't seem to make it work.

var tf=ss
       .createTextFinder(text)
       .useRegularExpression(true)
       .ignoreDiacritics(true)
       .startFrom(ss.getRange("B2"));
var all=tf.findAll();

我做错了什么?我得到结果,它们仍然只包含第1行和A列中的匹配项.

What am I doing wrong? I get results, they just still include matches from row 1 and column A.

推荐答案

假设ss是电子表格,您正在为整个电子表格创建文本查找器. startFrom(range)只说

Assuming ss is spreadsheet, you're creating a text finder for the entire spreadsheet. startFrom(range) only says

应从其开始搜索的单元格范围

The cell range after which the search should start

如果使用getCurrentMatch()findNext(),它将从该范围(即Sheet1!B2)开始返回与您的text条件相匹配的下一个范围.如果要特定于某个范围的textFinder,请在该范围内创建文本查找器:

If you use getCurrentMatch() or findNext() it'll return the next range matching your text criteria starting from that range(i.e., Sheet1!B2). If you want a textFinder specific to a range, then create the text finder on that range:

var tf = ss
    .getSheetByName('Sheet1')
    .getRange('B2:B')
    .createTextFinder(text)

这篇关于Google Apps脚本TextFinder startFrom不是从的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆