node.js - 如何将新工作表添加到现有电子表格中?带有 Node.js 的 Google 表格 API

标签 node.js google-sheets-api

使用适用于 Node.js 的 Google-Sheets-API,我如何以编程方式将新工作表添加/创建到现有电子表格中?

enter image description here

最佳答案

这实际上是可能的,并记录在 Spreadsheets/batchUpdate/Requests#AddSheetRequest

authorize(JSON.parse(clientSecretContent), (auth) => {
    const sheets = google.sheets({ version: 'v4', auth });
    const request = {
        // The ID of the spreadsheet
        "spreadsheetId": spreadsheetId,
        "resource": {
            "requests": [{
               "addSheet": {
                    // Add properties for the new sheet
                    "properties": {
                        // "sheetId": number,
                        // "title": sheetTitleSting,
                        // "index": number,
                        // "sheetType": enum(SheetType),
                        // "gridProperties": {
                        //     object(GridProperties)
                        // },
                        // "hidden": boolean,
                        // "tabColor": {
                        //     object(Color)
                        // },
                        // "rightToLeft": boolean
                    }
                }
            }]
        }
    };

    sheets.spreadsheets.batchUpdate(request, (err, response) => {
        if (err) {
            // TODO: Handle error
        } else {
            // TODO: Handle success
        }
    });
});

关于node.js - 如何将新工作表添加到现有电子表格中?带有 Node.js 的 Google 表格 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54819628/

相关文章:

node.js - Azure存储NodeJS修改默认超时设置

node.js - nodejs 表示 : hostname with port from the req object

javascript - 为 Node-RED 功能 block 上的每个输出返回一条消息

python - gspread update_cells 写入错误的位置

angular - Angular 中的 Google 表格 API

google-apps-script - 从工作表图表中提取替代文本 - Apps 脚本

python - 为什么我在调用 Google Sheets API 时收到 "Unknown Name..."名称错误?

node.js - 维护单独的 git 分支 - 一个用于 heroku,另一个用于 github

node.js - Sequelize.js - 选择正确的关系

google-app-engine - 从 Appengine 访问 Google Drive 电子表格