如何将数据过滤器添加到我的Google表格标题中 [英] How to add data filter to my google sheets header

查看:82
本文介绍了如何将数据过滤器添加到我的Google表格标题中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Google工作表的标题中添加一个过滤器.我发现此答案使用C#并尝试从中构建JSON.这是我想出的,但没有运气:

I want to add a filter to the header in my google sheet. I found THIS ANSWER using C# and tried to build the JSON from it. This is what I come up with but no luck :

{'AddFilterViewRequest' : {
      'AddFilterViewResponse': {
      'Filter' : {
                  'FilterView': {
                  'title' : "Hide rows with errors",
                  'range': {'sheetId': sheet_id,
                            'startRowIndex': 0,
                            'endRowIndex': 2,
                            'startColumnIndex': 1,
                            'endColumnIndex': 31}
                  }
      }
      }
}}

有人知道我要怎么做吗?

Anyone knows what I'm going wrong?

推荐答案

来自

"addFilterView": { # Adds a filter view. # Adds a filter view.
      "filter": { # A filter view. # The filter to add. The filterViewId
          # field is optional; if one is not set, an id will be randomly generated. (It
          # is an error to specify the ID of a filter that already exists.)
        "title": "A String", # The name of the filter view.
        "namedRangeId": "A String", # The named range this filter view is backed by, if any.
            #
            # When writing, only one of range or named_range_id
            # may be set.
        "filterViewId": 42, # The ID of the filter view.
        "range": { # A range on a sheet. # The range this filter view covers.
            #
            # When writing, only one of range or named_range_id
            # may be set.
            # All indexes are zero-based.
            # Indexes are half open, e.g the start index is inclusive
            # and the end index is exclusive -- [start_index, end_index).
            # Missing indexes indicate the range is unbounded on that side.
            #
            # For example, if `"Sheet1"` is sheet ID 0, then:
            #
            #   `Sheet1!A1:A1 == sheet_id: 0,
            #                   start_row_index: 0, end_row_index: 1,
            #                   start_column_index: 0, end_column_index: 1`
            #
            #   `Sheet1!A3:B4 == sheet_id: 0,
            #                   start_row_index: 2, end_row_index: 4,
            #                   start_column_index: 0, end_column_index: 2`
            #
            #   `Sheet1!A:B == sheet_id: 0,
            #                 start_column_index: 0, end_column_index: 2`
            #
            #   `Sheet1!A5:B == sheet_id: 0,
            #                  start_row_index: 4,
            #                  start_column_index: 0, end_column_index: 2`
            #
            #   `Sheet1 == sheet_id:0`
            #
            # The start index must always be less than or equal to the end index.
            # If the start index equals the end index, then the range is empty.
            # Empty ranges are typically not meaningful and are usually rendered in the
            # UI as `#REF!`.
          "endRowIndex": 42, # The end row (exclusive) of the range, or not set if unbounded.
          "endColumnIndex": 42, # The end column (exclusive) of the range, or not set if unbounded.
          "sheetId": 42, # The sheet this range is on.
          "startColumnIndex": 42, # The start column (inclusive) of the range, or not set if unbounded.
          "startRowIndex": 42, # The start row (inclusive) of the range, or not set if unbounded.
        },
        "sortSpecs": [ # The sort order per column. Later specifications are used when values
            # are equal in the earlier specifications.
          { # A sort order associated with a specific column or row.
            "sortOrder": "A String", # The order data should be sorted.
            "dimensionIndex": 42, # The dimension the sort should be applied to.
          },
        ],
        "criteria": { # The criteria for showing/hiding values per column.
            # The map's key is the column index, and the value is the criteria for
            # that column.
          "a_key": { # Criteria for showing/hiding rows in a filter or filter view.
            "hiddenValues": [ # Values that should be hidden.
              "A String",
            ],
            "condition": { # A condition that can evaluate to true or false. # A condition that must be true for values to be shown.
                # (This does not override hiddenValues -- if a value is listed there,
                #  it will still be hidden.)
                # BooleanConditions are used by conditional formatting,
                # data validation, and the criteria in filters.
              "values": [ # The values of the condition. The number of supported values depends
                  # on the condition type.  Some support zero values,
                  # others one or two values,
                  # and ConditionType.ONE_OF_LIST supports an arbitrary number of values.
                { # The value of the condition.
                  "relativeDate": "A String", # A relative date (based on the current date).
                      # Valid only if the type is
                      # DATE_BEFORE,
                      # DATE_AFTER,
                      # DATE_ON_OR_BEFORE or
                      # DATE_ON_OR_AFTER.
                      #
                      # Relative dates are not supported in data validation.
                      # They are supported only in conditional formatting and
                      # conditional filters.
                  "userEnteredValue": "A String", # A value the condition is based on.
                      # The value will be parsed as if the user typed into a cell.
                      # Formulas are supported (and must begin with an `=`).
                },
              ],
              "type": "A String", # The type of condition.
            },
          },
        },
      },
    }

我还没有尝试过使用过滤器,但是似乎不需要键AddFilterViewRequestAddFilterViewRequestFilter.

I haven't tried using a filter myself but it seems like the keys AddFilterViewRequest, AddFilterViewRequest and Filter aren't required.

这篇关于如何将数据过滤器添加到我的Google表格标题中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆