次の方法で共有


ExcelScript.PivotDateFilter interface

PivotField に適用する日付フィルターの構成可能なテンプレート。 は condition 、フィルターを動作させるために設定する必要がある条件を定義します。

プロパティ

comparator

コンパレータは、他の値が比較される静的な値です。 比較の種類は条件によって定義されます。

condition

必要なフィルター条件を定義するフィルターの条件を指定します。

exclusive

の場合true、フィルターは条件を満たす項目を除外します。 既定値は (条件を満たす項目を含むフィルター) です false

lowerBound

フィルター条件の範囲 between の下限。

upperBound

フィルター条件の範囲の between 上限。

wholeDays

beforeafterおよび between フィルター条件の場合equalsは、全体の日数として比較を行う必要があるかどうかを示します。

プロパティの詳細

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

beforeafterおよび between フィルター条件の場合equalsは、全体の日数として比較を行う必要があるかどうかを示します。

wholeDays?: boolean;

プロパティ値

boolean