从Google Sheets API获取过滤的数据 [英] Get filtered data from Google Sheets API

查看:448
本文介绍了从Google Sheets API获取过滤的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nodeJS从Google表格中获取数据,URL如下:

I am using nodeJS for fetching the data from google sheet and the URL looks like :

var url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet_key}/values/Sheet2!A1:J20?key=${google_API_key}`

由此,我只能获取A1到J20之间的数据,所以现在我有两个问题:

From this, I am only getting the data between A1 to J20 So now I have two questions :

  1. 如何从工作表或最后10条中获取所有行.
  2. 如何应用结构化查询过滤器,例如:where name =="Himanshu"

对于问题2:我所做的是使用查询语言参考(0.7版)/结构化查询,该查询由@Tanaike引用.这是我的网址的样子 就像现在一样,它也可以正常工作.
https://docs.google.com/a/google.com/spreadsheets/d/${sheet_key}/gviz/tq?tq=select%20*%20where%20B%20%3D%20'Himanshu'&key=${google_API_key}

For question 2: what I have done is using Query Language Reference (Version 0.7) / structured queries, which is referenced by @Tanaike. This is how my URL looks like now and its working as well.
https://docs.google.com/a/google.com/spreadsheets/d/${sheet_key}/gviz/tq?tq=select%20*%20where%20B%20%3D%20'Himanshu'&key=${google_API_key}

但是问题是它向我返回了我无法解析的类似这样的字符串.

But the issue is it's returning me the string something like this which I cant able to parse.

google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"509770406","table":{"cols":[{"id":"A","label":"Response Path","type":"string"},{"id":"B","label":"Name","type":"string"}]}})

推荐答案

此答案如何?

您可以使用工作表名称作为以下范围来检索所有行.

You can retrieve all rows using sheet name as the range as follows.

var url = `https://sheets.googleapis.com/v4/spreadsheets/${sheet_key}/values/Sheet2?key=${google_API_key}`

A2

您可以使用查询语言使用与where name == "Himanshu"类似的查询.为了使用此功能,请按以下方式共享电子表格.

A2

You can use the query like where name == "Himanshu" using Query Language. In order to use this, please share the Spreadsheet as follows.

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