本文介绍了是否可以一次隐藏多行Google电子表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在下面使用这个脚本(信用:Eduardo Kuwakino)。
我遇到的问题是它隐藏了列A中的行:A的值为x。
对编辑这些电子表格的人来说,是否可以让这种不痛?表格)
{
var maxRows = sheet.getMaxRows();

//显示所有行
sheet.showRows(1,maxRows);

//从数据库中获取数据A
var data = sheet.getRange('A:A')。getValues();

//遍历所有行
for(var i = 0; i< data.length; i ++){
//比较第一个字符,如果是星号,则隐藏行
if(data [i] [0] .charAt(0)=='x'){
sheet.hideRows(i + 1);

}}

函数onOpen(){
var sheets = SpreadsheetApp.getActiveSpreadsheet()。getSheets();

for(var i = 0; i< sheets.length; i ++){

hideCells(sheets [i]);
}
}


解决方案

是一种方法,它可以隐藏几行一次,但他们必须连续。在你的情况下,行一般不会连续。所以脚本必须一个一个地将它们隐藏起来(或者在几个碰巧在一起的时候也可以分组,但我认为这不会有多大帮助)。事实上,这在一张大单上会很慢。



另外,我建议您使用 = A2<>x

$ b过滤表格A
$ b


So I'm using this script below (credit: Eduardo Kuwakino).The problem I have that it hides the rows from column A:A with the value "x" one by one.Is it possible to make this "less painful" for the people who are editing these spreadsheets?

function hideCells(sheet)
{
    var maxRows = sheet.getMaxRows();

  //show all the rows
  sheet.showRows(1, maxRows);

  //get data from clumn A
  var data = sheet.getRange('A:A').getValues();

  //iterate over all rows
  for(var i=0; i< data.length; i++){
    //compare first character, if asterisk, then hide row
    if(data[i][0].charAt(0) == 'x'){
      sheet.hideRows(i+1);
    }
  }}

function onOpen() {
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();

  for(var i=0; i< sheets.length; i++){

      hideCells(sheets[i]);
  }
}
解决方案

There is a method hideRows which can hide several rows at once, but they must be consecutive. In your situation, the rows will not be consecutive in general. So script has to hide them one by one (or maybe in groups when a few happen to be together, but I don't think this will help much). And indeed, this will be slow in a large sheet.

As an alternative, I suggest using a filter view, specifically filter the sheet by the column A with custom formula =A2<>"x"

Each filter view has its own URL, which can be sent to people editing the spreadsheet. They will see only the rows where the value in A is different from "x".

这篇关于是否可以一次隐藏多行Google电子表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 23:12