使用Google API更新SpreadSheet [英] Update a SpreadSheet with the google API

查看:116
本文介绍了使用Google API更新SpreadSheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用node.js googleapis v4并使用JWT客户端进行授权来更新给定的电子表格单元格.

I'm trying to update a given spreadsheet cell, using node.js googleapis v4 and authorizing with a JWT client.

阅读效果很好,但我听不懂怎么写:

Reading works fine, but I cannot understand how to write:

    new Promise((resolve, reject) => {

            sheets.spreadsheets.values.update({
                auth: this._auth,
                spreadsheetId: this._metaData.spreadSheetId,
                range: range,
                valueInputOption: 'USER_ENTERED'
            },(err, resp) => {

                if (err) {
                    console.log('Data Error :', err)
                    reject(err);
                }

                resolve(resp);

            });

        });

如何指定数据,以及如何将其传递给呼叫?

How do I specify the data, and how do I pass it to the call?

我知道我应该使用ValueRange对象,但是如何使用?

I understand I should use a ValueRange object, but how?

推荐答案

在更好地阅读了(较差的)文档之后,我推断您必须在调用中传递请求对象:

After better reviewing the (poor) documentation, I inferred that you had to pass a request object in the call:

 return new Promise((resolve, reject) => {

            sheets.spreadsheets.values.update({
                auth: this._auth,
                spreadsheetId: this._metaData.spreadSheetId,
                range: range,
                valueInputOption: 'USER_ENTERED',
                resource: {range: 'Sheet1!A1',
                    majorDimension: 'ROWS',
                    values: [['b']]}
            } ,(err, resp) => {

                if (err) {
                    console.log('Data Error :', err)
                    reject(err);
                }

                resolve(resp);

            });

        });

这篇关于使用Google API更新SpreadSheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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