ExcelScript.PivotDateFilter interface

要应用于 PivotField 的日期筛选器的可配置模板。 定义 condition 需要设置哪些条件才能使筛选器运行。

属性

comparator

比较器是与其他值进行比较的静态值。 比较的类型由 条件定义。

condition

指定筛选器的条件,该条件定义必要的筛选条件。

exclusive

如果 true为 ,则筛选器 排除 满足条件的项目。 默认值为 false (筛选器,以包含符合条件) 的项。

lowerBound

筛选条件的范围的 between 下限。

upperBound

筛选条件的范围 between 上限。

wholeDays

对于 equalsbeforeafterbetween 筛选器条件,指示是否应将比较作为整天进行。

属性详细信息

comparator

比较器是与其他值进行比较的静态值。 比较的类型由 条件定义。

comparator?: FilterDatetime;

属性值

condition

指定筛选器的条件,该条件定义必要的筛选条件。

condition: DateFilterCondition;

属性值

示例

/**
 * This script applies a filter to a PivotTable that filters out rows 
 * that aren't from this month.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the "Date Recorded" field to filter. 
  // The data in this field must be dates in order for the filter to work.
  const pivot = workbook.getPivotTables()[0];
  const rowHierarchy = pivot.getRowHierarchy("Date Recorded");
  const rowField = rowHierarchy.getFields()[0];

  // Apply the date filter.
  rowField.applyFilter({
    dateFilter: {
      // Setting the condition to `thisMonth` means items that are before or
      // after this month will not be displayed.
      condition: ExcelScript.DateFilterCondition.thisMonth
    }
  });
}

exclusive

如果 true为 ,则筛选器 排除 满足条件的项目。 默认值为 false (筛选器,以包含符合条件) 的项。

exclusive?: boolean;

属性值

boolean

lowerBound

筛选条件的范围的 between 下限。

lowerBound?: FilterDatetime;

属性值

示例

/**
 * This script applies a filter to a PivotTable that filters it
 * to only show rows from between June 20th, 2022 and July 10th, 2022.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the "Date Recorded" field to filter. 
  // The data in this field must be dates in order for the filter to work.
  const pivot = workbook.getPivotTables()[0];
  const rowHierarchy = pivot.getRowHierarchy("Date Recorded");
  const rowField = rowHierarchy.getFields()[0];

  // Create the filter's date boundaries.
  let earliestDate: ExcelScript.FilterDatetime = {
    date: "2022-06-20",
    specificity: ExcelScript.FilterDatetimeSpecificity.day
  };
  let latestDate: ExcelScript.FilterDatetime = {
    date: "2022-07-10",
    specificity: ExcelScript.FilterDatetimeSpecificity.day
  };

  // Apply the date filter.
  rowField.applyFilter({
    dateFilter: {
      condition: ExcelScript.DateFilterCondition.between,
      lowerBound: earliestDate,
      upperBound: latestDate
    }
  });
}

upperBound

筛选条件的范围 between 上限。

upperBound?: FilterDatetime;

属性值

wholeDays

对于 equalsbeforeafterbetween 筛选器条件,指示是否应将比较作为整天进行。

wholeDays?: boolean;

属性值

boolean