我能够使用这样的代码你看到下面的一张纸上得值,但我想知道如果我能以某种方式从电子表格中所有的床单让所有的值,然后就操纵在我所得到的日期。换句话说,你可以设置范围,包括从片X到板Y表,或至少得到所有表中的所有数据,在那之后我会以某种方式设法包含/排除表。我使用的床单API,我不能使用此谷歌应用程序的脚本。
let { google } = require("googleapis");
let authentication = require("./authentication");
function getData(auth) {
var sheets = google.sheets('v4');
sheets.spreadsheets.values.get({
auth: auth,
spreadsheetId: '1XOqjUJ1eAMhl2g4KLIS4qPUzdwebSVeoE8OGJtPYyPw',
range: 'Test!A2:C', **//I would love to get all sheets. This is only one of them. Possible?**
}, (err, res) => {
if (err) {
console.log('The API returned an error: ' + err);
return res;
}
var rows = res.values;
if (rows.length === 0) {
console.log('No data found.');
} else {
for (var i = 0; i<= rows.length; i++) {
var row = rows[i];
console.log(row);
}
}
});
}
authentication.authenticate()
.then((auth) => {
getData(auth)
.catch((err) => {
console.log(err)
});
});
这是这样做的正确方法。我回答未来潜在的引用。
copyFormatToRange(片材,柱,columnEnd,行,rowEnd) 范围的格式复制到指定的位置。如果目的地是比源范围则源重复或相应截短更大或更小。注意,此方法只复制格式。
const ss = SpreadsheetApp.getActiveSpreadsheet();
const source = ss.getSheets()[0];
const destination = ss.getSheets()[1];
const range = source.getRange("B2:D4");
// This copies the formatting in B2:D4 in the source sheet to
// D4:F6 in the second sheet
range.copyFormatToRange(destination, 4, 6, 4, 6);
使用此方法需要授权一个或多个以下scopes的授权脚本:
- https://www.googleapis.com/auth/spreadsheets.currentonly - https://www.googleapis.com/auth/spreadsheets
这里是整个article。祝你好运吧:)
你可以参考这个blog如何将数据从使用查询公式多张相结合。下面是一个示例查询公式于上述两片的数据组合成一个单一的片材。
=query({junesheet!A2:H5;julysheet!A2:H5},”Select * where Col1 is not null “)
这里有额外的链接可能帮助:
希望这可以帮助!