我正在尝试Google的云功能服务,我想阅读和编写Google Spreadsheets,但似乎无法找到任何示例或方法来执行此操作.
我的问题是因为Google云功能的示例javascript是:
exports.helloWorld = function helloWorld (req, res) {
res.send(`Hello ${req.body.name || 'World'}!`);
};
Run Code Online (Sandbox Code Playgroud)
这有效,但我想以google为例从谷歌电子表格中读取:
gapi.load('client:auth2', initClient);
function initClient() {
gapi.client.init({
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
gapi.client.sheets.spreadsheets.values.get({
spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
range: 'Class Data!A2:E',
}).then(function(response) {
var range = response.result;
if (range.values.length > 0) {
appendPre('Name, Major:');
for (i = 0; i < range.values.length; i++) {
var row = range.values[i];
// Print columns A …
Run Code Online (Sandbox Code Playgroud)