Excel.PivotLayout class

ピボットテーブルの視覚的なレイアウトを表します。

Extends

プロパティ

autoFormat

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

context

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

layoutType

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

preserveFormatting

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

showColumnGrandTotals

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

showRowGrandTotals

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

subtotalLocation

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

メソッド

getColumnLabelRange()

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

getDataBodyRange()

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

getDataHierarchy(cell)

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

getFilterAxisRange()

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

getPivotItems(axis, cell)

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

getPivotItems(axis, 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, sortBy)

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

toJSON()

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

プロパティの詳細

autoFormat

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

autoFormat: boolean;

プロパティ値

boolean

注釈

API セット: ExcelApi 1.9

context

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

context: RequestContext;

プロパティ値

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 を取得する軸。 "row" または "column" である必要があります。

cell

Excel.Range | string

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

返品

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

注釈

API セット: ExcelApi 1.9

getPivotItems(axis, cell)

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

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

パラメーター

axis

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

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

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

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

返品

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, sortBy)

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

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

パラメーター

cell

Excel.Range | string

オートソートを適用するための条件の取得に使用する 1 つのセル。

sortBy

"Ascending" | "Descending"

並べ替えの方向。

返品

void

注釈

API セット: ExcelApi 1.9

toJSON()

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

toJSON(): Excel.Interfaces.PivotLayoutData;

返品