我有一个名为Main-spreadsheet的电子表格,其中有4个电子表格,名为sheet1,sheet2,sheet3&结果。我想将条件数据从sheet1,sheet2,sheet3复制到结果表。任何人都可以帮助我????
这是我的代码:
var ss = SpreadsheetApp.openById(DATA_SPREADSHEET_ID);
var sheet = ss.getSheets()[3];
var dataSs = SpreadsheetApp.openById(DATA_SPREADSHEET_ID);
var dataSheet = dataSs.getSheets()[0];
// Fetch all the data
var data = getRowsData(dataSheet);
// This is the data we want to display
var columnNames = ["Name", "AC link", "Type"];
// Index data by type
var dataBytype = {};
var types = [];
for (var i = 0; i < data.length; ++i) {
var rowData = data[i];
if (!dataBytype[rowData.type]) {
dataBytype[rowData.type] = [];
types.push(rowData.type);
}
dataBytype[rowData.type].push(rowData);
}
types.sort();
var headerBackgroundColor = dataSheet.getRange(1, 1).getBackgroundColor();
for (var i = 0; i < types.length; ++i) {
var sheet = ss.getSheetByName(types[i]) ||
ss.insertSheet(types[i], ss.getSheets().length);
sheet.clear();
var headersRange = sheet.getRange(1, 1, 1, columnNames.length);
headersRange.setValues([columnNames]);
headersRange.setBackgroundColor(headerBackgroundColor);
setRowsData(sheet, dataBytype[types[i]]);
}
}
它目前复制数据fom sheet1并按类型列
创建一个新工作表