Share via


ExcelScript.Filter interface

テーブルの列のフィルター処理を管理します。

注釈

/**
 * This script adds a table filter to only show the top 10% of values 
 * belonging to a particular column.
 */
function main(workbook: ExcelScript.Workbook) {
    // Get the first table on the current worksheet.
    const table = workbook.getActiveWorksheet().getTables()[0];

    // Get the filter for the "PageViews" table column.
    const pageViewFilter : ExcelScript.Filter = table.getColumnByName("PageViews").getFilter();

    // Apply a filter to only show the rows with the top 10% of values in this column.
    pageViewFilter.applyTopPercentFilter(10);
}

メソッド

apply(criteria)

指定の列に、指定したフィルター条件を適用します。

applyBottomItemsFilter(count)

指定した数の要素の列に "下位アイテム" フィルターを適用します。

applyBottomPercentFilter(percent)

指定した割合の要素の列に "下位パーセント" フィルターを適用します。

applyCellColorFilter(color)

指定した色の列に "セルの色" フィルターを適用します。

applyCustomFilter(criteria1, criteria2, oper)

指定した条件文字列の列に "アイコン" フィルターを適用します。

applyDynamicFilter(criteria)

列に "動的" フィルターを適用します。

applyFontColorFilter(color)

指定した色の列に "フォントの色" フィルターを適用します。

applyIconFilter(icon)

指定したアイコンの列に "アイコン" フィルターを適用します。

applyTopItemsFilter(count)

指定した数の要素の列に "上位アイテム" フィルターを適用します。

applyTopPercentFilter(percent)

指定した割合の要素の列に "上位パーセント" フィルターを適用します。

applyValuesFilter(values)

指定した値の列に "値" フィルターを適用します。

clear()

指定した列に適用されているフィルターをクリアします。

getCriteria()

指定した列に現在適用されているフィルターです。

メソッドの詳細

apply(criteria)

指定の列に、指定したフィルター条件を適用します。

apply(criteria: FilterCriteria): void;

パラメーター

criteria
ExcelScript.FilterCriteria

適用する基準。

戻り値

void

applyBottomItemsFilter(count)

指定した数の要素の列に "下位アイテム" フィルターを適用します。

applyBottomItemsFilter(count: number): void;

パラメーター

count

number

表示する下位からの要素の数。

戻り値

void

applyBottomPercentFilter(percent)

指定した割合の要素の列に "下位パーセント" フィルターを適用します。

applyBottomPercentFilter(percent: number): void;

パラメーター

percent

number

表示する下位からの要素のパーセンテージ。

戻り値

void

applyCellColorFilter(color)

指定した色の列に "セルの色" フィルターを適用します。

applyCellColorFilter(color: string): void;

パラメーター

color

string

表示するセルの背景色です。

戻り値

void

applyCustomFilter(criteria1, criteria2, oper)

指定した条件文字列の列に "アイコン" フィルターを適用します。

applyCustomFilter(
            criteria1: string,
            criteria2?: string,
            oper?: FilterOperator
        ): void;

パラメーター

criteria1

string

最初の条件の文字列です。

criteria2

string

オプション。 2 つ目の条件の文字列です。

oper
ExcelScript.FilterOperator

省略可能です。 2 つの条件を結合する方法を記述する演算子です。

戻り値

void

/**
 * The script filters rows from a table based on numerical values.
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the first table in the current worksheet.
  const currentSheet = workbook.getActiveWorksheet();
  const table = currentSheet.getTables()[0];

  // Filter to only show rows with values in the "Sales" column that are 
  // greater than or equal to 2000.
  table.getColumnByName("Sales").getFilter().applyCustomFilter(">=2000");
}

applyDynamicFilter(criteria)

列に "動的" フィルターを適用します。

applyDynamicFilter(criteria: DynamicFilterCriteria): void;

パラメーター

criteria
ExcelScript.DynamicFilterCriteria

適用する動的条件。

戻り値

void

/**
 * This script applies a filter to a table that filters it 
 * to only show rows with dates from the previous month.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the table named "ReportTable".
  const table = workbook.getTable("ReportTable");

  // Get the column with the header "Date".
  const dateColumn = table.getColumnByName("Date");

  // Apply a dynamic filter to the column. 
  // `lastMonth` will only show rows with a date from the previous month.
  dateColumn.getFilter().applyDynamicFilter(ExcelScript.DynamicFilterCriteria.lastMonth);
}

applyFontColorFilter(color)

指定した色の列に "フォントの色" フィルターを適用します。

applyFontColorFilter(color: string): void;

パラメーター

color

string

表示するセルのフォントの色です。

戻り値

void

applyIconFilter(icon)

指定したアイコンの列に "アイコン" フィルターを適用します。

applyIconFilter(icon: Icon): void;

パラメーター

icon
ExcelScript.Icon

表示するセルのアイコンです。

戻り値

void

applyTopItemsFilter(count)

指定した数の要素の列に "上位アイテム" フィルターを適用します。

applyTopItemsFilter(count: number): void;

パラメーター

count

number

表示する上位からの要素の数。

戻り値

void

applyTopPercentFilter(percent)

指定した割合の要素の列に "上位パーセント" フィルターを適用します。

applyTopPercentFilter(percent: number): void;

パラメーター

percent

number

表示する上位からの要素のパーセンテージ。

戻り値

void

applyValuesFilter(values)

指定した値の列に "値" フィルターを適用します。

applyValuesFilter(values: Array<string | FilterDatetime>): void;

パラメーター

values

Array<string | ExcelScript.FilterDatetime>

表示する値のリスト。 これは、文字列の配列またはオブジェクトの ExcelScript.FilterDateTime 配列である必要があります。

戻り値

void

/**
 * This script applies a filter to a table so that it only shows rows with "Needs Review" in the "Type" column.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first table in the workbook.
  const table = workbook.getTables()[0];

  // Apply the filter to the "Type" column.
  const typeColumn = table.getColumnByName("Type");
  typeColumn.getFilter().applyValuesFilter(["Needs Review"]);
}

clear()

指定した列に適用されているフィルターをクリアします。

clear(): void;

戻り値

void

/**
 * This script shows how to clear a filter from a table column.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first table in the workbook.
  const table = workbook.getTables()[0];

  // Clear the filter for the table column named "Status".
  const statusColumnFilter = table.getColumn("Status").getFilter();
  statusColumnFilter.clear();
}

getCriteria()

指定した列に現在適用されているフィルターです。

getCriteria(): FilterCriteria;

戻り値