如何从Google表格访问单元格值? [英] How to access cell values from a Google Sheet?

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

问题描述

我很难找到有关我所需要的信息.我想我没有在正确的位置中寻找,因为这是非常基本的.无论如何.

I have the greatest trouble finding information about what I need. I guess I'm not looking in the right places since this is quite basic. Anyway.

某处有人创建了Google表格,任何知道链接的人都可以访问.我想检索给定单元格的值.

我希望能够通过一个简单的网页在JS中完成以下 (或者在PHP中是服务器端,但最好是JS)

I'd like to be able to do the following in JS from a simple web page (or server side in PHP, but preferably JS):

AGoogleApiIHopeExists.setApiKey("<MY_API_KEY");
var value = AGoogleApiIHopeExists
    .getSheet("AJEIDNNS6886SDHSKN67HBS7BA6SD555DSHD")
    .getTab("MyTabInsideMySheet")
    .getCell("B:17");

恐怕我有点天真,以为这是可能的...

I'm afraid I'm a bit naive to think this is possible...

如果没有,我应该在哪里寻找更多信息?

If not, where should I look for more info?

推荐答案

尝试通读 Google表格API .这是一个REST API,您可以使用它访问&编辑Google表格.您不需要不需要他们的客户端库(Java,.NET等)

Try reading through the Google Sheets API. It is a REST API you can use to access & edit Google sheets. You do not need their client libraries (Java, .NET, etc.)

如果工作表是私人的,则您将需要使用OAuth 2.0来通过用户帐户进行访问.

If the sheet is private, you will need to use OAuth 2.0 to gain access through a user account.

如果工作表是公开的,则无需登录即可访问它.请注意,尽管该工作表仍必须发布,然后才能访问它.

If the sheet is public, you will be able to access it without login. Note though that the sheet must still be published before you can access it.

我做了一些挖掘工作以帮助您.尝试以下端点:

I did some digging to help you out. Try this endpoint:

https://spreadsheets.google.com/feeds/cells/<sheetID>/default/public/full/R1C1?alt=json

R1C1 引用第1行第1列.您可以根据需要进行更改. default 是指工作表(标签)的ID.如果您需要与默认工作表不同的工作表,则可以使用其他API端点来获取适当的工作表ID.

R1C1 refers to Row 1, Column 1. You can change this as needed. default refers to the worksheet (tab) ID. If you need a different worksheet than the default, there are other API endpoints you can use to fetch the appropriate worksheet ID.

这是一个简单的jsfiddle ,可让您输入一些变量并查看结果值.

Here is a simple jsfiddle which allows you to enter a few variables and see the resulting value.

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

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