ExcelScript.PivotField interface

Excel PivotField を表します。

メソッド

applyFilter(filter)

フィールドの現在の PivotFilter を 1 つ以上設定し、フィールドに適用します。 指定されたフィルターが無効であるか、適用できない場合は、例外がスローされます。

clearAllFilters()

すべてのフィールドのフィルターからすべての条件をクリアします。 これにより、フィールドのアクティブなフィルター処理が削除されます。

clearFilter(filterType)

指定された型のフィールドのフィルターから既存のすべての条件をクリアします (現在適用されている場合)。

getFilters()

フィールドに現在適用されているすべてのフィルターを取得します。

getId()

PivotField の ID。

getItems()

PivotField に関連付けられている PivotItems を返します。

getName()

PivotField の名前。

getPivotItem(name)

名前で PivotItem を取得します。 PivotItem が存在しない場合、このメソッドは を返します undefined

getShowAllItems()

PivotField のすべての項目を表示するかどうかを指定します。

getSubtotals()

PivotField の小計。

isFiltered(filterType)

フィールドに適用されたフィルターがあるかどうかを確認します。

setName(name)

PivotField の名前。

setShowAllItems(showAllItems)

PivotField のすべての項目を表示するかどうかを指定します。

setSubtotals(subtotals)

PivotField の小計。

sortByLabels(sortBy)

PivotField を並べ替えます。 DataPivotHierarchy を指定すると、そのピボット階層に基づいて並べ替えが適用されます。指定しない場合、ピボット フィールド自体が並べ替えの基準になります。

sortByValues(sortBy, valuesHierarchy, pivotItemScope)

与えられた範囲で、指定された値に基づいて PivotField を並べ替えます。 スコープは、同じ DataPivotHierarchy から複数の値がある場合に並べ替えに使用する特定の値を定義します。

メソッドの詳細

applyFilter(filter)

フィールドの現在の PivotFilter を 1 つ以上設定し、フィールドに適用します。 指定されたフィルターが無効であるか、適用できない場合は、例外がスローされます。

applyFilter(filter: PivotFilters): void;

パラメーター

filter
ExcelScript.PivotFilters

構成済みの特定の PivotFilter、または複数の構成済みフィルターを含む PivotFilters インターフェイス。

戻り値

void

/**
 * This script applies a PivotValueFilter to the first row hierarchy in the PivotTable.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable on the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let pivotTable = sheet.getPivotTables()[0];

  // Get the first row hierarchy to use as the field which gets filtered.
  let rowHierarchy = pivotTable.getRowHierarchies()[0];

  // Get the first data hierarchy to use as the values for filtering the rows.
  let dataHierarchy = pivotTable.getDataHierarchies()[0];

  // Create a filter that excludes values greater than 500.
  let filter: ExcelScript.PivotValueFilter = {
    condition: ExcelScript.ValueFilterCondition.greaterThan,
    comparator: 500,
    value: dataHierarchy.getName()
  };

  // Apply the filter.
  rowHierarchy.getPivotField(rowHierarchy.getName()).applyFilter({
    valueFilter: filter
  });
}

clearAllFilters()

すべてのフィールドのフィルターからすべての条件をクリアします。 これにより、フィールドのアクティブなフィルター処理が削除されます。

clearAllFilters(): void;

戻り値

void

clearFilter(filterType)

指定された型のフィールドのフィルターから既存のすべての条件をクリアします (現在適用されている場合)。

clearFilter(filterType: PivotFilterType): void;

パラメーター

filterType
ExcelScript.PivotFilterType

すべての条件をクリアするフィールドのフィルターの種類。

戻り値

void

/**
 * This script gets the "Type" field from the "Farms Sales" PivotTable 
 * and clears the value filter from it.
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable named "Farm Sales".
  const pivot = workbook.getPivotTable("Farm Sales");

  // Get the "Type" field.
  const typeField = pivot.getHierarchy("Type").getPivotField("Type");

  // Clear the value filter (if there is one) from the field.
  typeField.clearFilter(ExcelScript.PivotFilterType.value);
}

getFilters()

フィールドに現在適用されているすべてのフィルターを取得します。

getFilters(): PivotFilters;

戻り値

getId()

PivotField の ID。

getId(): string;

戻り値

string

getItems()

PivotField に関連付けられている PivotItems を返します。

getItems(): PivotItem[];

戻り値

getName()

PivotField の名前。

getName(): string;

戻り値

string

getPivotItem(name)

名前で PivotItem を取得します。 PivotItem が存在しない場合、このメソッドは を返します undefined

getPivotItem(name: string): PivotItem | undefined;

パラメーター

name

string

取得する PivotItem の名前。

戻り値

ExcelScript.PivotItem | undefined

getShowAllItems()

PivotField のすべての項目を表示するかどうかを指定します。

getShowAllItems(): boolean;

戻り値

boolean

getSubtotals()

PivotField の小計。

getSubtotals(): Subtotals;

戻り値

isFiltered(filterType)

フィールドに適用されたフィルターがあるかどうかを確認します。

isFiltered(filterType?: PivotFilterType): boolean;

パラメーター

filterType
ExcelScript.PivotFilterType

チェックするフィルターの種類。 型が指定されていない場合、このメソッドはフィルターが適用された場合にチェックします。

戻り値

boolean

setName(name)

PivotField の名前。

setName(name: string): void;

パラメーター

name

string

戻り値

void

setShowAllItems(showAllItems)

PivotField のすべての項目を表示するかどうかを指定します。

setShowAllItems(showAllItems: boolean): void;

パラメーター

showAllItems

boolean

戻り値

void

setSubtotals(subtotals)

PivotField の小計。

setSubtotals(subtotals: Subtotals): void;

パラメーター

戻り値

void

sortByLabels(sortBy)

PivotField を並べ替えます。 DataPivotHierarchy を指定すると、そのピボット階層に基づいて並べ替えが適用されます。指定しない場合、ピボット フィールド自体が並べ替えの基準になります。

sortByLabels(sortBy: SortBy): void;

パラメーター

sortBy
ExcelScript.SortBy

並べ替えが昇順または降順で行われるかどうかを指定します。

戻り値

void

sortByValues(sortBy, valuesHierarchy, pivotItemScope)

与えられた範囲で、指定された値に基づいて PivotField を並べ替えます。 スコープは、同じ DataPivotHierarchy から複数の値がある場合に並べ替えに使用する特定の値を定義します。

sortByValues(
            sortBy: SortBy,
            valuesHierarchy: DataPivotHierarchy,
            pivotItemScope?: Array<PivotItem | string>
        ): void;

パラメーター

sortBy
ExcelScript.SortBy

並べ替えが昇順または降順で行われるかどうかを指定します。

valuesHierarchy
ExcelScript.DataPivotHierarchy

並べ替えに使用するデータ軸の値階層を指定します。

pivotItemScope

Array<ExcelScript.PivotItem | string>

並べ替えのスコープに使用する必要がある項目。 これらは、並べ替える行または列を構成する項目です。 PivotItem の代わりに文字列を使用する場合、文字列は PivotItem の ID を表します。 並べ替える軸にデータ階層以外の項目がない場合は、空にすることができます。

戻り値

void

/**
 * This sample sorts the rows of a PivotTable.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get an existing PivotTable.
  const pivotTable = workbook.getPivotTable("Farm Sales");

  // Get the data hierarchy to use as the basis of the sort.
  const valueFieldToSortOn = pivotTable.getDataHierarchy("Sum of Crates Sold Wholesale");

  // Get the row to sort.
  const rowToSort = pivotTable.getRowHierarchy("Farm");

  // Sort the "Farm" row's only field by the values in "Sum of Crates Sold Wholesale".
  rowToSort.getFields()[0].sortByValues(ExcelScript.SortBy.descending, valueFieldToSortOn);
}