我在Google云端硬盘中有一个电子表格,其中还有5个电子表格,可以从文档主spreadsheet[0]
的副本中提供信息。我已在G列中的每个其他电子表格[1],[2],[3],[4]
上设置过滤器,范围为('G1:G1000')
我有一个脚本,但没有选择这些额外电子表格中的特定列
感谢您的帮助!
function onOpen(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var filterMenuEntries = [{name: "filter Column1", functionName: "filter"}];
ss.addMenu("choose filter", filterMenuEntries);
}
function filter(){
//spreadsheet identifier
var key = '1X7qA--8UxVj37SHON14F4KdrF3DDPpKMtUmhgHVmt51GW4c';
var ss = SpreadsheetApp.openById(key);
var rows = sheet.getDataRange('G1:G1000');// should I set a range here?
var numRows = rows.getNumRows();
var values = rows.getValues();
ss.getActiveSheet();
for (var i=1; i <=numRows -1; i++){
var row =values[i];
// Column value
var myValue = row[8] //not sure if this is column 'G' or not
// filter value
if (myValue == "DEVPS"){
sheet.hideRows(i+1);
}
}
答案 0 :(得分:0)
您应该更改此行:
var ss = SpreadsheetApp.openById(key);
到
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = ss.getSheets()[1];
并按照您的意愿使用sheet1(和其他人)。