Google APIs 学习/使用

1.应用场景

了解并使用Google APIs, 用于开发当中.

2.学习/操作

背景:

公司开发有用到Google APIs,所以只能去了解.

1.介绍

简单说, 就是Google提供操作Google文档的api,

方便在项目使用code进行操作.

2.操作

https://developers.google.com/apis-explorer  //Google APIs Explorer

https://developers.google.com/sheets/api/reference/rest  //在Google APIs Explorer, 搜索sheets之后的结果

https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values  //REST Resource: spreadsheets.values

后续补充

...

3.问题/补充

1.如何使用api获取Google Spreadsheet中的行数?

参考: https://stackoom.com/question/178iy/如何使用api获取Google-Spreadsheet中的行数

查了文档,以及Google搜索之后,发现只是支持Python进行查询获取rowCount

nodeJS解决办法:

折中办法,自行记录rowCount,然后获取.

async function updateRowsCount(sheets, spreadsheetId, sheetName){
    const res = await sheets.spreadsheets.values.update({
        spreadsheetId: spreadsheetId,
        range: `${sheetName}!${LastRowCountCell}`,
        valueInputOption: 'USER_ENTERED',
        requestBody: {
            values: [
                ['=COUNT(A:A)'],
            ],
        },
    })
    return res.data;
}

这种办法,会每次更新rowCount,然后再查询获取rowCount值

优化:

应该继续查询文档或者nodeJS组件,或者可以考虑自己试着去写组件。//TBD

4.参考

https://github.com/googleapis/google-api-nodejs-client/#google-apis  //googleapis/google-api-nodejs-client

https://developers.google.com/apis-explorer  //Google APIs Explorer

https://stackoverflow.com/questions/61749543/how-to-get-the-correct-parameters-for-the-googleapi-nodejs-client //How to get the correct parameters for the googleapi-nodejs-client

后续补充

...

猜你喜欢

转载自blog.csdn.net/william_n/article/details/106338736
今日推荐