凡示例代码展示了如何使用Google Data Java Client Library其支持OAuth 2.0与Google Spreadsheet API(现称Google Sheets API)?
java oauth google-spreadsheet-api google-api-java-client google-sheets-api
我试图在谷歌官方文档之后阅读和编写python 3中不同表单的值.虽然我能够使用rangeName = 'Class Data!A2:E'下面提到的代码块中的range属性读取某些工作表中的值:
discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
'version=v4')
service = discovery.build('sheets', 'v4', http=http,
discoveryServiceUrl=discoveryUrl)
spreadsheetId = '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'
rangeName = 'Class Data!A2:E'
result = service.spreadsheets().values().get(
spreadsheetId=spreadsheetId, range=rangeName).execute()
values = result.get('values', [])
Run Code Online (Sandbox Code Playgroud)
requests.append({
'updateCells': {
'start': {'sheetId': 0, 'rowIndex': 0, 'columnIndex': 0},
'rows': [
{
'values': [
{
'userEnteredValue': {'numberValue': 1},
'userEnteredFormat': {'backgroundColor': {'red': 1}}
}, {
'userEnteredValue': {'numberValue': 2},
'userEnteredFormat': {'backgroundColor': {'blue': 1}}
}, {
'userEnteredValue': {'numberValue': 3},
'userEnteredFormat': {'backgroundColor': {'green': …Run Code Online (Sandbox Code Playgroud) 我想在Google云端硬盘中创建一个空的Google表格(仅使用元数据创建).当我提到Google SpreadSheet API文档时,它说要使用DocumentsList API,但它已被弃用,而是要求我使用Google Drive API.在Drive API文档中,我找不到任何方法来创建空Sheet.任何人都知道如何做到这一点?
python google-drive-api google-api-python-client google-sheets-api
有没有人有一个很好的C#示例用于使用v4 API更新单元格?
我在使用Google表格API v4的开发者网站上获得了获取单元格值c#示例.我试图修改示例以更新值为"Tom"的单元格.我坚持设置SpreadSheets.Values.Update.
using Google.Apis.Auth.OAuth2;
using Google.Apis.Sheets.v4;
using Google.Apis.Sheets.v4.Data;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GoogleSheetsAPI4_v1console
{
class Program
{
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/sheets.googleapis.com-dotnet-quickstart.json
static string[] Scopes = { SheetsService.Scope.Spreadsheet };
static string ApplicationName = "TestSpreadsheet";
static void Main(string[] args)
{
UserCredential credential;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = …Run Code Online (Sandbox Code Playgroud) c# google-api google-sheets google-api-dotnet-client google-sheets-api
我有一个应用程序可以打开我已发布到网络上的电子表格的 json 版本。我使用了该网站上的说明: https ://www.freecodecamp.org/news/cjn-google-sheets-as-json-endpoint/
几个月来一直工作正常,但今天我意识到我的 json 文件的 url 从昨天开始就不再工作了。它显示消息:“抱歉,目前无法打开文件。请检查地址并重试。” 不过,以网页形式查看电子表格的常规链接仍然有效。
Google 是否放弃了对此功能的支持?还有其他方法可以通过 URL 获取 json 格式的电子表格数据吗?我开始研究 Google Developer API,但它确实令人困惑。
我在运行针对公众(即"发布到网络"并与"网络上的任何人"共享)电子表格时,从谷歌表格API的v4获得回复是没有运气的.
相关文件说明:
"如果请求不需要授权(例如请求公共数据),那么应用程序必须提供API密钥或OAuth 2.0令牌,或两者兼而有之 - 无论哪种选项对您来说都是最方便的."
并提供API密钥,文档说明:
"拥有API密钥后,您的应用程序可以将查询参数key = yourAPIKey附加到所有请求URL."
因此,我应该能够在以下网址的公共电子表格中找到列出工作表的回复:
https://sheets.googleapis.com/v4/spreadsheets/ {spreadsheetId}?key = {myAPIkey}
(显然,分别在路径和查询字符串中提供的id和密钥)
但是,当我这样做时,我得到一个HTTP 401响应:
{
error: {
code: 401,
message: "The request does not have valid authentication credentials.",
status: "UNAUTHENTICATED"
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以让这个对公共工作簿起作用吗?如果没有,那么从谷歌那边监控这个主题的人是否可以评论或提供工作样本?
我想阅读Java快速入门中描述的Google电子表格
https://developers.google.com/sheets/quickstart/java
快速入门说明了如何从给定范围读取数据
.....
String range = "Class Data!A2:E";
ValueRange response = service.spreadsheets().values()
.get(spreadsheetId, range)
.execute();
List<List<Object>> values = response.getValues();
....
Run Code Online (Sandbox Code Playgroud)
但我有一个问题,我不知道电子表格的范围.列数可以更改.那么如何在不知道范围的情况下阅读Sheet的所有数据呢?
问候
迈克尔
我正在尝试从cron中读取文档:
https://sheets.googleapis.com/v4/spreadsheets/<sheet_id>?key=<api_key>
任何有链接的人都可以使用我的文档.
My #1 key settings:
Application restrictions:
- IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
- API restrictions - none
Run Code Online (Sandbox Code Playgroud)
My #2 key settings:
Application restrictions:
- IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
- API restrictions - Google Sheets API
Run Code Online (Sandbox Code Playgroud)
My #3 key settings:
Application restrictions:
- IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
- API …Run Code Online (Sandbox Code Playgroud) 我已经通过Google官方文档开发人员指南Spreadsheet API中提到的简单Java代码在My Google Drive帐户的现有电子表格中成功创建了一个新的工作表,但我想创建一个新的电子表格通过java代码在我的Google云端硬盘帐户中.在上面提到的链接中,他们没有提到任何示例代码.我经历过许多链接,但没有得到怎么办?我已经在Spreadservice类中看到了不同的方法.
我没有了解如何使用Google Spreadsheet API?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.Link;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.TextConstruct;
import com.google.gdata.data.docs.ExportFormat;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
import java.util.*;
import javax.xml.soap.Text;
/**
*
* @author satyam
*/
public class SpreadSheet {
public static void main(String[] args)
throws AuthenticationException, MalformedURLException, IOException, ServiceException {
SpreadsheetService service = new SpreadsheetService("gBuddy");
// TODO: …Run Code Online (Sandbox Code Playgroud) 我有一个googlesheet,其中列可能不包含任何信息.在遍历行并查看该列时,如果列为空,则不会返回任何内容.更糟糕的是,如果我得到一个完整的行并包括那个常见的,比如获得5列,当任何列为空时,我只返回4列.如果我得到一行列并且列中的一个单元格为空,如何返回NULL或空字符串?
// Build a new authorized API client service.
Sheets service = GoogleSheets.getSheetsService();
range = "Functional Users!A3:E3";
response = service.spreadsheets().values().get(spreadsheetId, range).execute();
values = response.getValues();
cells = values.get(0);
Run Code Online (Sandbox Code Playgroud)
我在行中得到了5个单元格.cells.size()应该总是返回五.但是,如果5个细胞中的任何一个是空白的,它将返回更少的细胞.假设只有B3的单元格为空.cells.size()将为4.下一次迭代,我得到A4:E4,单元格D4为空.同样,cells.size()将是4.无法知道哪个单元格丢失.如果A4和D4和E4为空,则cells.size()将为2.
无论空单元格如何,如何让它返回5个单元格?