如何使用Google-sheet-apis(Node.js)从Google-Sheet中提取特定行? [英] How to fetch Specific row from google-sheet by using Google-sheet-apis(Node.js)?

查看:223
本文介绍了如何使用Google-sheet-apis(Node.js)从Google-Sheet中提取特定行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用google-apis SDK进行开发.我可以使用sheets.spreadsheets.values.get方法从工作表中获取值.但是它从该工作表返回整个值.我需要过滤类似查询的内容.

I used google-apis SDK for my development. I can able to get values from sheet by using sheets.spreadsheets.values.get method. But it returns entire values from that sheet. I need to filter something like querying.

这是我真正尝试的,

示例工作表图像

假设上述数据为电子表格,在这里sheets.spreadsheets.values.get将从该工作表返回整个值.但是我尝试通过Email=surya@aaa.com

Assume the above data as a spreadsheet, Here sheets.spreadsheets.values.get this returns whole values from that sheet. But I try to do fetch first row by Email=surya@aaa.com

推荐答案

方法 spreadsheets.values.get 允许(并要求)指定范围

The method spreadsheets.values.get allows (and requires) you to specify a range

range的样本值-为获取Sheet1的第5行将为Sheet1!A5:Z5

A sample value for range - for getting row 5 of Sheet1 would be Sheet1!A5:Z5

更新

如果您不知道要检索哪一行,但想合并一个查询请求(例如在Google表格用户界面中),则可以:

If you do not know which row you want to retrieve, but want to incorporate a query request, such as in the Google Sheets UI:

无法使用Google Sheets API.

但是有一种解决方法:

使用Google 可视化API查询.

Use a Google Visualization API query.

工作流程:

  • 将电子表格发布为具有链接的任何人都可以查看"
  • 通过以下方式创建URL
    • 获取电子表格的基本URL https://docs.google.com/a/google.com/spreadsheets/d/XXXXXX
    • 添加到URL /gviz/tq?tq=
    • 例如在表格用户界面中创建查询并对其进行URL编码
    • 将URL编码的查询添加到您的URL
    • Publish your spreadsheet as "Anyone with the link can view"
    • Create the URL by
      • taking the basic URL of your spreadsheet https://docs.google.com/a/google.com/spreadsheets/d/XXXXXX
      • add to the URL /gviz/tq?tq=
      • create you query such as in Sheets UI and URL encode it
      • Add the URL encoded query to your URL

      示例:

      如果您的查询是select A

      • URL将为https://docs.google.com/spreadsheets/d/XXXXX/gviz/tq?tq=select%20A
      • 并且GET请求的响应将是:
      google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"1023816999","table":{"cols":[{"id":"A","label":"","type":"number","pattern":"General"}],"rows":[{"c":[{"v":1.0,"f":"1"}]},{"c":[{"v":4.0,"f":"4"}]}],"parsedNumHeaders":0}});
      

      您可以根据需要访问嵌套的JSON结构,当然也可以根据需要制定查询条件.

      You can access the nested JSON structure as desired and of course you can formulate your query as desired.

      这篇关于如何使用Google-sheet-apis(Node.js)从Google-Sheet中提取特定行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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