ExcelScript.PivotTable interface

Excel のピボットテーブルを表します。

注釈

/**
 * This script creates a PivotTable from an existing table and adds it to a new worksheet.
 * This script assumes there is a table in the current worksheet with columns named "Type" and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Create a PivotTable based on a table in the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let table = sheet.getTables()[0];

  // Add the PivotTable to a new worksheet.
  let newSheet = workbook.addWorksheet("Pivot");
  let pivotTable = newSheet.addPivotTable("My Pivot", table, "A1");

  // Add fields to the PivotTable to show "Sales" per "Type".
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

メソッド

addColumnHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

addDataHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。

addFilterHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

addRowHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

delete()

ピボットテーブルを削除します。

getAllowMultipleFiltersPerField()

ピボットテーブルで、テーブル内の特定のピボットフィールドに対して複数のピボットフィルターを適用できるかどうかを指定します。

getColumnHierarchies()

ピボットテーブルの列ピボット階層。

getColumnHierarchy(name)

名前に基づいて RowColumnPivotHierarchy を取得します。 RowColumnPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getDataHierarchies()

ピボットテーブルのデータ ピボット階層。

getDataHierarchy(name)

名前に基づいて DataPivotHierarchy を取得します。 DataPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getEnableDataValueEditing()

ピボットテーブルでデータ本文の値をユーザーが編集できるかどうかを指定します。

getFilterHierarchies()

ピボットテーブルのフィルター ピボット階層。

getFilterHierarchy(name)

名前に基づいて FilterPivotHierarchy を取得します。 FilterPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getHierarchies()

ピボットテーブルのピボット階層。

getHierarchy(name)

名前に基づいて PivotHierarchy を取得します。 PivotHierarchy が存在しない場合、このメソッドは を返します undefined

getId()

ピボットテーブルの ID。

getLayout()

ピボットテーブルのレイアウトとビジュアル構造を記述する PivotLayout。

getName()

ピボットテーブルの名前。

getRowHierarchies()

ピボットテーブルの行ピボット階層。

getRowHierarchy(name)

名前に基づいて RowColumnPivotHierarchy を取得します。 RowColumnPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getUseCustomSortLists()

並べ替え時にピボットテーブルでカスタム リストを使用するかどうかを指定します。

getWorksheet()

現在のピボットテーブルを含んでいるワークシート。

refresh()

ピボットテーブルを更新します。

removeColumnHierarchy(rowColumnPivotHierarchy)

現在の軸からピボット階層を削除します。

removeDataHierarchy(DataPivotHierarchy)

現在の軸からピボット階層を削除します。

removeFilterHierarchy(filterPivotHierarchy)

現在の軸からピボット階層を削除します。

removeRowHierarchy(rowColumnPivotHierarchy)

現在の軸からピボット階層を削除します。

setAllowMultipleFiltersPerField(allowMultipleFiltersPerField)

ピボットテーブルで、テーブル内の特定のピボットフィールドに対して複数のピボットフィルターを適用できるかどうかを指定します。

setEnableDataValueEditing(enableDataValueEditing)

ピボットテーブルでデータ本文の値をユーザーが編集できるかどうかを指定します。

setName(name)

ピボットテーブルの名前。

setUseCustomSortLists(useCustomSortLists)

並べ替え時にピボットテーブルでカスタム リストを使用するかどうかを指定します。

メソッドの詳細

addColumnHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

addColumnHierarchy(
            pivotHierarchy: PivotHierarchy
        ): RowColumnPivotHierarchy;

パラメーター

戻り値

/**
 * This script adds a row hierarchy to the PivotTable on the current worksheet.
 * This assumes the source data has columns named 
 * "Type", "Classification", and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable on the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let pivotTable = sheet.getPivotTables()[0];

  // Add the field "Type" to the PivotTable as a row hierarchy.
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));

  // Add the field "Classification" to the PivotTable as a column hierarchy.
  pivotTable.addColumnHierarchy(pivotTable.getHierarchy("Classification"));

  // Add the field "Sales" to the PivotTable as a data hierarchy.
  // By default, this displays the sums of the values in "Sales" based on the "Type".
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

addDataHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。

addDataHierarchy(pivotHierarchy: PivotHierarchy): DataPivotHierarchy;

パラメーター

戻り値

/**
 * This script creates a PivotTable from an existing table and adds it to a new worksheet.
 * This script assumes there is a table in the current worksheet with columns named "Type" and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Create a PivotTable based on a table in the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let table = sheet.getTables()[0];

  // Add the PivotTable to a new worksheet.
  let newSheet = workbook.addWorksheet("Pivot");
  let pivotTable = newSheet.addPivotTable("My Pivot", table, "A1");

  // Add fields to the PivotTable to show "Sales" per "Type".
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

addFilterHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

addFilterHierarchy(
            pivotHierarchy: PivotHierarchy
        ): FilterPivotHierarchy;

パラメーター

戻り値

/**
 * This script adds a manual filter to a PivotTable. 
 */
function main(workbook: ExcelScript.Workbook)
{
  // Get the first PivotTable in the workbook.
  const pivot = workbook.getPivotTables()[0];

  // Get the hierarchy to use as the filter.
  const location = pivot.getHierarchy("Location");

  // Use "Location" as the FilterHierarchy.
  pivot.addFilterHierarchy(location);

  // Select items for the filter.
  // Note that hierarchies and fields have a 1:1 relationship in Excel,
  // so `getFields()[0]` always gets the correct field.
  location.getFields()[0].applyFilter({
    manualFilter: {
      selectedItems: ["Seattle", "Chicago"]
    }
  });
}

addRowHierarchy(pivotHierarchy)

現在の軸にピボット階層を追加します。 階層が行、列、またはフィルター軸の他の場所に存在する場合は、その場所から削除されます。

addRowHierarchy(
            pivotHierarchy: PivotHierarchy
        ): RowColumnPivotHierarchy;

パラメーター

戻り値

/**
 * This script creates a PivotTable from an existing table and adds it to a new worksheet.
 * This script assumes there is a table in the current worksheet with columns named "Type" and "Sales".
 */
function main(workbook: ExcelScript.Workbook) {
  // Create a PivotTable based on a table in the current worksheet.
  let sheet = workbook.getActiveWorksheet();
  let table = sheet.getTables()[0];

  // Add the PivotTable to a new worksheet.
  let newSheet = workbook.addWorksheet("Pivot");
  let pivotTable = newSheet.addPivotTable("My Pivot", table, "A1");

  // Add fields to the PivotTable to show "Sales" per "Type".
  pivotTable.addRowHierarchy(pivotTable.getHierarchy("Type"));
  pivotTable.addDataHierarchy(pivotTable.getHierarchy("Sales"));
}

delete()

ピボットテーブルを削除します。

delete(): void;

戻り値

void

getAllowMultipleFiltersPerField()

ピボットテーブルで、テーブル内の特定のピボットフィールドに対して複数のピボットフィルターを適用できるかどうかを指定します。

getAllowMultipleFiltersPerField(): boolean;

戻り値

boolean

getColumnHierarchies()

ピボットテーブルの列ピボット階層。

getColumnHierarchies(): RowColumnPivotHierarchy[];

戻り値

getColumnHierarchy(name)

名前に基づいて RowColumnPivotHierarchy を取得します。 RowColumnPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getColumnHierarchy(name: string): RowColumnPivotHierarchy | undefined;

パラメーター

name

string

取得する RowColumnPivotHierarchy の名前。

戻り値

getDataHierarchies()

ピボットテーブルのデータ ピボット階層。

getDataHierarchies(): DataPivotHierarchy[];

戻り値

getDataHierarchy(name)

名前に基づいて DataPivotHierarchy を取得します。 DataPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getDataHierarchy(name: string): DataPivotHierarchy | undefined;

パラメーター

name

string

取得する DataPivotHierarchy の名前。

戻り値

getEnableDataValueEditing()

ピボットテーブルでデータ本文の値をユーザーが編集できるかどうかを指定します。

getEnableDataValueEditing(): boolean;

戻り値

boolean

getFilterHierarchies()

ピボットテーブルのフィルター ピボット階層。

getFilterHierarchies(): FilterPivotHierarchy[];

戻り値

getFilterHierarchy(name)

名前に基づいて FilterPivotHierarchy を取得します。 FilterPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getFilterHierarchy(name: string): FilterPivotHierarchy | undefined;

パラメーター

name

string

取得する FilterPivotHierarchy の名前。

戻り値

getHierarchies()

ピボットテーブルのピボット階層。

getHierarchies(): PivotHierarchy[];

戻り値

getHierarchy(name)

名前に基づいて PivotHierarchy を取得します。 PivotHierarchy が存在しない場合、このメソッドは を返します undefined

getHierarchy(name: string): PivotHierarchy | undefined;

パラメーター

name

string

取得する PivotHierarchy の名前。

戻り値

getId()

ピボットテーブルの ID。

getId(): string;

戻り値

string

getLayout()

ピボットテーブルのレイアウトとビジュアル構造を記述する PivotLayout。

getLayout(): PivotLayout;

戻り値

/**
 * This script sets the layout of the "Farms Sales" PivotTable to the "tabular"
 * setting. This places the fields from the Rows area in separate columns.
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the PivotTable named "Farm Sales".
  const pivot = workbook.getPivotTable("Farm Sales");

  // Get the PivotLayout object.
  const layout = pivot.getLayout();

  // Set the layout type to "tabular".
  layout.setLayoutType(ExcelScript.PivotLayoutType.tabular);
}

getName()

ピボットテーブルの名前。

getName(): string;

戻り値

string

getRowHierarchies()

ピボットテーブルの行ピボット階層。

getRowHierarchies(): RowColumnPivotHierarchy[];

戻り値

getRowHierarchy(name)

名前に基づいて RowColumnPivotHierarchy を取得します。 RowColumnPivotHierarchy が存在しない場合、このメソッドは を返します undefined

getRowHierarchy(name: string): RowColumnPivotHierarchy | undefined;

パラメーター

name

string

取得する RowColumnPivotHierarchy の名前。

戻り値

/**
 * 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);
}

getUseCustomSortLists()

並べ替え時にピボットテーブルでカスタム リストを使用するかどうかを指定します。

getUseCustomSortLists(): boolean;

戻り値

boolean

getWorksheet()

現在のピボットテーブルを含んでいるワークシート。

getWorksheet(): Worksheet;

戻り値

refresh()

ピボットテーブルを更新します。

refresh(): void;

戻り値

void

removeColumnHierarchy(rowColumnPivotHierarchy)

現在の軸からピボット階層を削除します。

removeColumnHierarchy(
            rowColumnPivotHierarchy: RowColumnPivotHierarchy
        ): void;

パラメーター

rowColumnPivotHierarchy
ExcelScript.RowColumnPivotHierarchy

戻り値

void

removeDataHierarchy(DataPivotHierarchy)

現在の軸からピボット階層を削除します。

removeDataHierarchy(DataPivotHierarchy: DataPivotHierarchy): void;

パラメーター

DataPivotHierarchy
ExcelScript.DataPivotHierarchy

戻り値

void

removeFilterHierarchy(filterPivotHierarchy)

現在の軸からピボット階層を削除します。

removeFilterHierarchy(filterPivotHierarchy: FilterPivotHierarchy): void;

パラメーター

filterPivotHierarchy
ExcelScript.FilterPivotHierarchy

戻り値

void

removeRowHierarchy(rowColumnPivotHierarchy)

現在の軸からピボット階層を削除します。

removeRowHierarchy(
            rowColumnPivotHierarchy: RowColumnPivotHierarchy
        ): void;

パラメーター

rowColumnPivotHierarchy
ExcelScript.RowColumnPivotHierarchy

戻り値

void

setAllowMultipleFiltersPerField(allowMultipleFiltersPerField)

ピボットテーブルで、テーブル内の特定のピボットフィールドに対して複数のピボットフィルターを適用できるかどうかを指定します。

setAllowMultipleFiltersPerField(
            allowMultipleFiltersPerField: boolean
        ): void;

パラメーター

allowMultipleFiltersPerField

boolean

戻り値

void

setEnableDataValueEditing(enableDataValueEditing)

ピボットテーブルでデータ本文の値をユーザーが編集できるかどうかを指定します。

setEnableDataValueEditing(enableDataValueEditing: boolean): void;

パラメーター

enableDataValueEditing

boolean

戻り値

void

setName(name)

ピボットテーブルの名前。

setName(name: string): void;

パラメーター

name

string

戻り値

void

setUseCustomSortLists(useCustomSortLists)

並べ替え時にピボットテーブルでカスタム リストを使用するかどうかを指定します。

setUseCustomSortLists(useCustomSortLists: boolean): void;

パラメーター

useCustomSortLists

boolean

戻り値

void