如何搜索 Google 电子表格? [英] How do I search Google Spreadsheets?

查看:56
本文介绍了如何搜索 Google 电子表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了一些详尽的搜索,需要确定新域 (URL) 是否已经在电子表格中.但是,没有一个电子表格对象具有搜索功能,即在大多数文档对象中找到的 findText().我觉得我错过了一些重要的东西.我错过了什么?

I am doing a few exhaustive searches and need to determine if a new domain (URL) is already in a Spreadsheet. However, none of the Spreadsheet objects have search functions, namely findText() found in most Document objects. I feel like I am missing something significant. What am I missing?

findText 函数:https://developers.google.com/apps-script/class_table#findText

findText function: https://developers.google.com/apps-script/class_table#findText

SearchResult 对象:https://developers.google.com/apps-script/class_searchresult

SearchResult object: https://developers.google.com/apps-script/class_searchresult

电子表格对象:https://developers.google.com/apps-script/class_sheet

我最好的猜测是尝试转换文档表中的特定电子表格范围,然后执行搜索.门德斋

My best guess is to try and convert specific Spreadsheet ranges in Document tables, then perform the search. Mendokusai

推荐答案

遗憾的是,电子表格服务中没有搜索功能.您可以获取正在搜索的范围的数据,然后对其进行迭代以寻找匹配项.这是一个简单的函数:

Unfortunately there is no searching functionality in the Spreadsheet services. You can get the data for the range you are searching on, and then iterate over it looking for a match. Here's a simple function that does that:

/**
 * Finds a value within a given range. 
 * @param value The value to find.
 * @param range The range to search in.
 * @return A range pointing to the first cell containing the value, 
 *     or null if not found.
 */
function find(value, range) {
  var data = range.getValues();
  for (var i = 0; i < data.length; i++) {
    for (var j = 0; j < data[i].length; j++) {
      if (data[i][j] == value) {
        return range.getCell(i + 1, j + 1);
      }
    }
  }
  return null;
}

这篇关于如何搜索 Google 电子表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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