Share via


Excel.PivotLayout class

ピボットテーブルのビジュアル レイアウトを表します。

Extends

注釈

[ API セット: ExcelApi 1.8 ]

プロパティ

autoFormat

更新時またはフィールドの移動時に書式を自動的に設定するかどうかを指定します。

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

enableFieldList

フィールド リストを UI に表示できるかどうかを指定します。

layoutType

このプロパティは、ピボットテーブルのすべてのフィールドの PivotLayoutType を示します。 フィールドによって状態が異なる場合は null 値になります。

preserveFormatting

ピボット、並べ替え、ページ フィールド 項目の変更などの操作によってレポートを更新または再計算するときに、書式設定を保持するかどうかを指定します。

showColumnGrandTotals

ピボットテーブル レポートに列の総計を表示するかどうかを指定します。

showRowGrandTotals

ピボットテーブル レポートに行の総計を表示するかどうかを指定します。

subtotalLocation

このプロパティは、 SubtotalLocationType ピボットテーブルのすべてのフィールドの を示します。 フィールドの状態が異なる場合、これは になります null

メソッド

getColumnLabelRange()

ピボットテーブルの列ラベルが存在する範囲を返します。

getDataBodyRange()

ピボットテーブルのデータ値が存在する範囲を返します。

getDataHierarchy(cell)

PivotTable 内で指定された範囲の値を計算するために使用される DataHierarchy を取得します。

getFilterAxisRange()

ピボットテーブルのフィルター エリアの範囲を返します。

getPivotItems(axis, cell)

PivotTable 内で指定された範囲の値を構成する PivotItems を軸から取得します。

getPivotItems(axisString, cell)

PivotTable 内で指定された範囲の値を構成する PivotItems を軸から取得します。

getRange()

フィルター エリアを除く、ピボットテーブルが存在する範囲を返します。

getRowLabelRange()

ピボットテーブルの行ラベルが存在する範囲を返します。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

setAutoSortOnCell(cell, sortBy)

必要なすべての条件とコンテキストを自動的に選択するため、指定したセルを使用して自動的に並べ替えを実行するようピボットテーブルを設定します。 これは、UI から自動並べ替えを適用するのと同じ動作です。

setAutoSortOnCell(cell, sortByString)

必要なすべての条件とコンテキストを自動的に選択するため、指定したセルを使用して自動的に並べ替えを実行するようピボットテーブルを設定します。 これは、UI から自動並べ替えを適用するのと同じ動作です。

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の Excel.PivotLayout オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.PivotLayoutData型指定) を返します。

プロパティの詳細

autoFormat

更新時またはフィールドの移動時に書式を自動的に設定するかどうかを指定します。

autoFormat: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.9 ]

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

enableFieldList

フィールド リストを UI に表示できるかどうかを指定します。

enableFieldList: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.10 ]

layoutType

このプロパティは、ピボットテーブルのすべてのフィールドの PivotLayoutType を示します。 フィールドによって状態が異なる場合は null 値になります。

layoutType: Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline";

プロパティ値

Excel.PivotLayoutType | "Compact" | "Tabular" | "Outline"

注釈

[ API セット: ExcelApi 1.8 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Change the PivotLayout.type to a new type.
  const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");
  pivotTable.layout.load("layoutType");
  await context.sync();

  // Cycle between the three layout types.
  if (pivotTable.layout.layoutType === "Compact") {
    pivotTable.layout.layoutType = "Outline";
  } else if (pivotTable.layout.layoutType === "Outline") {
    pivotTable.layout.layoutType = "Tabular";
  } else {
    pivotTable.layout.layoutType = "Compact";
  }

  await context.sync();
  console.log("Pivot layout is now " + pivotTable.layout.layoutType);
});

preserveFormatting

ピボット、並べ替え、ページ フィールド 項目の変更などの操作によってレポートを更新または再計算するときに、書式設定を保持するかどうかを指定します。

preserveFormatting: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.9 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Set whether the PivotTable keeps the established format after it is refreshed and recalculated.
  const pivotTable = context.workbook.pivotTables.getItem("Farm Sales");
  const pivotLayout = pivotTable.layout;

  pivotLayout.load("preserveFormatting");
  await context.sync();

  let preserveFormattingToSet = !pivotLayout.preserveFormatting;
  console.log(`Preserve the formatting PivotTable after a refresh? - ${preserveFormattingToSet}`);

  pivotLayout.preserveFormatting = preserveFormattingToSet;
  await context.sync();
});

showColumnGrandTotals

ピボットテーブル レポートに列の総計を表示するかどうかを指定します。

showColumnGrandTotals: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.8 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Turn the grand totals on and off for the rows and columns.
  const pivotTable = context.workbook.pivotTables.getItem("Farm Sales");
  const pivotLayout = pivotTable.layout;

  pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]);
  await context.sync();

  let showColumnTotals = !pivotLayout.showColumnGrandTotals;
  let showRowTotals = !pivotLayout.showRowGrandTotals;
  console.log(`Show column grand totals? - ${showColumnTotals}`);
  console.log(`Show row grand totals? - ${showRowTotals}`);

  pivotLayout.showColumnGrandTotals = showColumnTotals;
  pivotLayout.showRowGrandTotals = showRowTotals;

  await context.sync();
});

showRowGrandTotals

ピボットテーブル レポートに行の総計を表示するかどうかを指定します。

showRowGrandTotals: boolean;

プロパティ値

boolean

注釈

[ API セット: ExcelApi 1.8 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-pivotlayout.yaml

await Excel.run(async (context) => {
  // Turn the grand totals on and off for the rows and columns.
  const pivotTable = context.workbook.pivotTables.getItem("Farm Sales");
  const pivotLayout = pivotTable.layout;

  pivotLayout.load(["showRowGrandTotals", "showColumnGrandTotals"]);
  await context.sync();

  let showColumnTotals = !pivotLayout.showColumnGrandTotals;
  let showRowTotals = !pivotLayout.showRowGrandTotals;
  console.log(`Show column grand totals? - ${showColumnTotals}`);
  console.log(`Show row grand totals? - ${showRowTotals}`);

  pivotLayout.showColumnGrandTotals = showColumnTotals;
  pivotLayout.showRowGrandTotals = showRowTotals;

  await context.sync();
});

subtotalLocation

このプロパティは、 SubtotalLocationType ピボットテーブルのすべてのフィールドの を示します。 フィールドの状態が異なる場合、これは になります null

subtotalLocation: Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off";

プロパティ値

Excel.SubtotalLocationType | "AtTop" | "AtBottom" | "Off"

注釈

[ API セット: ExcelApi 1.8 ]

メソッドの詳細

getColumnLabelRange()

ピボットテーブルの列ラベルが存在する範囲を返します。

getColumnLabelRange(): Excel.Range;

戻り値

注釈

[ API セット: ExcelApi 1.8 ]

getDataBodyRange()

ピボットテーブルのデータ値が存在する範囲を返します。

getDataBodyRange(): Excel.Range;

戻り値

注釈

[ API セット: ExcelApi 1.8 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/38-pivottable/pivottable-filters-and-summaries.yaml

await Excel.run(async (context) => {
    const pivotTable = context.workbook.worksheets.getActiveWorksheet().pivotTables.getItem("Farm Sales");

    // The layout controls the ranges used by the PivotTable.
    const range = pivotTable.layout.getDataBodyRange();

    // Get all the data hierarchy totals.
    const grandTotalRange = range.getLastRow();
    grandTotalRange.load("address");
    await context.sync();
    
    // Use the wholesale and farm sale totals to make a final sum.
    const masterTotalRange = context.workbook.worksheets.getActiveWorksheet().getRange("B27:C27");
    masterTotalRange.formulas = [["All Crates", "=SUM(" + grandTotalRange.address + ")"]];
    await context.sync();
});

getDataHierarchy(cell)

PivotTable 内で指定された範囲の値を計算するために使用される DataHierarchy を取得します。

getDataHierarchy(cell: Range | string): Excel.DataPivotHierarchy;

パラメーター

cell

Excel.Range | string

ピボットテーブル データ本文内の 1 つのセル。

戻り値

指定したセル内の値の計算に使用される DataPivotHierarchy オブジェクト。

注釈

[ API セット: ExcelApi 1.9 ]

getFilterAxisRange()

ピボットテーブルのフィルター エリアの範囲を返します。

getFilterAxisRange(): Excel.Range;

戻り値

注釈

[ API セット: ExcelApi 1.8 ]

getPivotItems(axis, cell)

PivotTable 内で指定された範囲の値を構成する PivotItems を軸から取得します。

getPivotItems(axis: Excel.PivotAxis, cell: Range | string): Excel.PivotItemCollection;

パラメーター

axis
Excel.PivotAxis

PivotItems を取得する軸。 "行" または "列" である必要があります。

cell

Excel.Range | string

ピボットテーブルのデータ本文内の 1 つのセル。

戻り値

指定した行の値を計算するために使用される PivotItems の PivotItemCollection。

注釈

[ API セット: ExcelApi 1.9 ]

getPivotItems(axisString, cell)

PivotTable 内で指定された範囲の値を構成する PivotItems を軸から取得します。

getPivotItems(axisString: "Unknown" | "Row" | "Column" | "Data" | "Filter", cell: Range | string): Excel.PivotItemCollection;

パラメーター

axisString

"Unknown" | "Row" | "Column" | "Data" | "Filter"

PivotItems を取得する軸。 "行" または "列" である必要があります。

cell

Excel.Range | string

ピボットテーブルのデータ本文内の 1 つのセル。

戻り値

指定した行の値を計算するために使用される PivotItems の PivotItemCollection。

注釈

[ API セット: ExcelApi 1.9 ]

getRange()

フィルター エリアを除く、ピボットテーブルが存在する範囲を返します。

getRange(): Excel.Range;

戻り値

注釈

[ API セット: ExcelApi 1.8 ]

getRowLabelRange()

ピボットテーブルの行ラベルが存在する範囲を返します。

getRowLabelRange(): Excel.Range;

戻り値

注釈

[ API セット: ExcelApi 1.8 ]

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: Excel.Interfaces.PivotLayoutLoadOptions): Excel.PivotLayout;

パラメーター

options
Excel.Interfaces.PivotLayoutLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): Excel.PivotLayout;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Excel.PivotLayout;

パラメーター

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties: Interfaces.PivotLayoutUpdateData, options?: OfficeExtension.UpdateOptions): void;

パラメーター

properties
Excel.Interfaces.PivotLayoutUpdateData

メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。

戻り値

void

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

set(properties: Excel.PivotLayout): void;

パラメーター

properties
Excel.PivotLayout

戻り値

void

setAutoSortOnCell(cell, sortBy)

必要なすべての条件とコンテキストを自動的に選択するため、指定したセルを使用して自動的に並べ替えを実行するようピボットテーブルを設定します。 これは、UI から自動並べ替えを適用するのと同じ動作です。

setAutoSortOnCell(cell: Range | string, sortBy: Excel.SortBy): void;

パラメーター

cell

Excel.Range | string

使用する 1 つのセルは、自動ソートを適用するための条件を取得します。

sortBy
Excel.SortBy

並べ替えの方向。

戻り値

void

注釈

[ API セット: ExcelApi 1.9 ]

setAutoSortOnCell(cell, sortByString)

必要なすべての条件とコンテキストを自動的に選択するため、指定したセルを使用して自動的に並べ替えを実行するようピボットテーブルを設定します。 これは、UI から自動並べ替えを適用するのと同じ動作です。

setAutoSortOnCell(cell: Range | string, sortByString: "Ascending" | "Descending"): void;

パラメーター

cell

Excel.Range | string

使用する 1 つのセルは、自動ソートを適用するための条件を取得します。

sortByString

"Ascending" | "Descending"

並べ替えの方向。

戻り値

void

注釈

[ API セット: ExcelApi 1.9 ]

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出 toJSON します)。元の Excel.PivotLayout オブジェクトは API オブジェクトですが、メソッドは、元の toJSON オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.PivotLayoutData型指定) を返します。

toJSON(): Excel.Interfaces.PivotLayoutData;

戻り値