简体   繁体   English

Google电子表格过滤器列

[英]Google Spreadsheet Filter Column

I have a Spreadsheet within Google Drive that has 5 more spreadsheets feeding information from a copy of the main spreadsheet[0] of the document. 我在Google云端硬盘中有一个电子表格,其中还有5个电子表格从文档的主要spreadsheet[0]的副本中获取信息。 I have made filters on each of the other spreadsheets [1],[2],[3],[4] in column G with the range ('G1:G1000') I have a script but is not picking the specific columns in those extra spreadsheets 我在G列中每个其他电子表格[1],[2],[3],[4]的范围为('G1:G1000')都有过滤器。我有一个脚本,但未选择其中的特定列这些额外的电子表格

Thanks for the help! 谢谢您的帮助!

   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);

     }

  }

You should change this line: 您应该更改此行:

var ss = SpreadsheetApp.openById(key);

To

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = ss.getSheets()[1];

and work with sheet1 (and others) as you wish. 并根据需要使用sheet1(和其他)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM