您好我正在使用 googleapis npm包来处理电子表格。我有一个用于复制电子表格的功能,但问题是它只复制一张纸,但我的源电子表格有多张纸。
这是我的代码: -
const { google } = require('googleapis');
var sheet_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
..
..
..
function copySpreadSheet(authClient, sheet_id) {
console.log('sheet_id', sheet_id)
const sheets = google.sheets({ version: 'v4', authClient });
sheets.spreadsheets.create({
auth: authClient,
resource: {
properties: {
title: "New Sheet " + new Date()
}
}
}, (err, response) => {
if (err) {
console.log('The API returned an error: ' + err);
return;
} else {
console.log(response.data)
var request = {
spreadsheetId: sheet_id,
sheetId: 0, // HERE I SOMETHING MISSING
resource: {
destinationSpreadsheetId: response.data.spreadsheetId
},
auth: authClient,
};
sheets.spreadsheets.sheets.copyTo(request, function (err, response2) {
if (err) {
console.error(err);
return;
}
console.log(response2.data);
});
console.log("Added");
}
});
}