在node.js中的google sheet api中使用copyTo函数

时间:2016-12-12 15:17:16

标签: node.js google-sheets-api

我试图通过node.js在Google工作表api中使用copyTo函数,其中它会将工作表从一个电子表格复制到另一个电子表格。这是我的代码:

function copySheet(auth){
var sheets = google.sheets('v4');
var spreadsheetID_foo = 'some spreadsheet id';
var spreadsheetID_test = 'another spreadsheet id';

sheets.spreadsheets.sheets.copyTo({
    auth: auth,
    sheetId: 0,
    spreadsheetId: spreadsheetID_test,
    resource: {properties: {destinationSpreadsheetId: spreadsheetID_foo}}
}, function(err,response){
    if(err) {
        console.log(err);
    }
    console.log('Data :', response);
});
}

然而,弹出错误并显示“缺少必需参数:sheetId”。但是在代码中,我已经声明了所述参数。我已成功使用API​​中的其他命令,但这个copyTo函数是我无法弄清楚的。有人可以在这里指导我做错了吗?非常感谢你。

2 个答案:

答案 0 :(得分:0)

从Google Apps脚本中查看此documentation,了解如何使用copyTo(电子表格)功能。

它将工作表复制到给定的电子表格,该电子表格可以是与源相同的电子表格。复制的工作表将命名为“[原始名称]的副本”。

var source = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = source.getSheets()[0];

 var destination = SpreadsheetApp.openById('ID_GOES HERE');
 sheet.copyTo(destination);

答案 1 :(得分:0)

//替换

updated_in

//与

app = Application(backend="win32").connect(process=12345)
form = app.window(title_re="windowtitle")
form.send_keystrokes("1234567")