ExcelScript.PivotLayout interface

表示数据透视表的视觉布局。

方法

displayBlankLineAfterEachItem(display)

设置是否在每个项目后显示空白行。 这是在数据透视表的全局级别设置的,并应用于单个透视字段。 此函数将数据透视表中所有字段的设置覆盖为 参数的值 display

getAltTextDescription()

数据透视表的替换文字说明。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

getAltTextTitle()

数据透视表的替换文字标题。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

getAutoFormat()

指定在刷新时还是移动字段时自动设置格式设置格式。

getBodyAndTotalRange()

返回数据透视表数据值所在位置的区域。

getColumnLabelRange()

返回数据透视表列标签所在位置的区域。

getDataHierarchy(cell)

获取 DataHierarchy,它用于计算数据透视表中指定区域内的值。

getEmptyCellText()

如果 fillEmptyCells == true,则自动填充到数据透视表中的任何空单元格中的文本。 请注意,如果 fillEmptyCells 设置为 false,则此值会保留,并且设置此值不会将该属性设置为 true。 默认情况下,这是一个空字符串。

getEnableFieldList()

指定是否可以在 UI 中显示字段列表。

getFillEmptyCells()

指定是否应使用 填充数据透视表中的 emptyCellText空单元格。 默认值为 false。 请注意,当此属性设置为 false时,emptyCellText的值将保留。

getFilterAxisRange()

返回数据透视表筛选区的区域。

getLayoutType()

此属性指示数据透视表上的所有字段的 PivotLayoutType。 如果字段状态不同,则为 null。

getPreserveFormatting()

指定在通过透视、排序或更改页字段项等作刷新或重新计算报表时是否保留格式。

getRange()

返回存在数据透视表的区域,不包括筛选区。

getRowLabelRange()

返回数据透视表行标签所在位置的区域。

getShowColumnGrandTotals()

指定数据透视表是否显示列的总计。

getShowFieldHeaders()

指定数据透视表是否) 显示字段标题 (字段标题和筛选器下拉列表。

getShowRowGrandTotals()

指定数据透视表是否显示行的总计。

getSubtotalLocation()

此属性指示 SubtotalLocationType 数据透视表上所有字段的 。 如果字段具有不同的状态,则为 null

repeatAllItemLabels(repeatLabels)

设置数据透视表中所有字段的“重复所有项目标签”设置。

setAltTextDescription(altTextDescription)

数据透视表的替换文字说明。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

setAltTextTitle(altTextTitle)

数据透视表的替换文字标题。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

setAutoFormat(autoFormat)

指定在刷新时还是移动字段时自动设置格式设置格式。

setAutoSortOnCell(cell, sortBy)

将数据透视表设置为使用指定的单元格设置自动排序,以自动选择排序的所有条件和上下文。 这与从 UI 应用自动排序的行为相同。

setEmptyCellText(emptyCellText)

如果 fillEmptyCells == true,则自动填充到数据透视表中的任何空单元格中的文本。 请注意,如果 fillEmptyCells 设置为 false,则此值会保留,并且设置此值不会将该属性设置为 true。 默认情况下,这是一个空字符串。

setEnableFieldList(enableFieldList)

指定是否可以在 UI 中显示字段列表。

setFillEmptyCells(fillEmptyCells)

指定是否应使用 填充数据透视表中的 emptyCellText空单元格。 默认值为 false。 请注意,当此属性设置为 false时,emptyCellText的值将保留。

setLayoutType(layoutType)

此属性指示数据透视表上的所有字段的 PivotLayoutType。 如果字段状态不同,则为 null。

setPreserveFormatting(preserveFormatting)

指定在通过透视、排序或更改页字段项等作刷新或重新计算报表时是否保留格式。

setShowColumnGrandTotals(showColumnGrandTotals)

指定数据透视表是否显示列的总计。

setShowFieldHeaders(showFieldHeaders)

指定数据透视表是否) 显示字段标题 (字段标题和筛选器下拉列表。

setShowRowGrandTotals(showRowGrandTotals)

指定数据透视表是否显示行的总计。

setSubtotalLocation(subtotalLocation)

此属性指示 SubtotalLocationType 数据透视表上所有字段的 。 如果字段具有不同的状态,则为 null

方法详细信息

displayBlankLineAfterEachItem(display)

设置是否在每个项目后显示空白行。 这是在数据透视表的全局级别设置的,并应用于单个透视字段。 此函数将数据透视表中所有字段的设置覆盖为 参数的值 display

displayBlankLineAfterEachItem(display: boolean): void;

参数

display

boolean

如果为 True,则会打开空白行显示设置。 False 会将其关闭。

返回

void

getAltTextDescription()

数据透视表的替换文字说明。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

getAltTextDescription(): string;

返回

string

getAltTextTitle()

数据透视表的替换文字标题。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

getAltTextTitle(): string;

返回

string

getAutoFormat()

指定在刷新时还是移动字段时自动设置格式设置格式。

getAutoFormat(): boolean;

返回

boolean

getBodyAndTotalRange()

返回数据透视表数据值所在位置的区域。

getBodyAndTotalRange(): Range;

返回

示例

/**
 * This sample finds the first PivotTable in the workbook and logs the values in the "Grand Total" cells.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first PivotTable in the workbook.
  let pivotTable = workbook.getPivotTables()[0];

  // Get the names of each data column in the PivotTable.
  let pivotColumnLabelRange = pivotTable.getLayout().getColumnLabelRange();

  // Get the range displaying the pivoted data.
  let pivotDataRange = pivotTable.getLayout().getBodyAndTotalRange();

  // Get the range with the "grand totals" for the PivotTable columns.
  let grandTotalRange = pivotDataRange.getLastRow();

  // Print each of the "Grand Totals" to the console.
  grandTotalRange.getValues()[0].forEach((column, columnIndex) => {
    console.log(`Grand total of ${pivotColumnLabelRange.getValues()[0][columnIndex]}: ${grandTotalRange.getValues()[0][columnIndex]}`);
    // Example log: "Grand total of Sum of Crates Sold Wholesale: 11000"
  });
}

getColumnLabelRange()

返回数据透视表列标签所在位置的区域。

getColumnLabelRange(): Range;

返回

getDataHierarchy(cell)

获取 DataHierarchy,它用于计算数据透视表中指定区域内的值。

getDataHierarchy(cell: Range | string): DataPivotHierarchy;

参数

cell

ExcelScript.Range | string

数据透视表数据正文中的单个单元格。

返回

getEmptyCellText()

如果 fillEmptyCells == true,则自动填充到数据透视表中的任何空单元格中的文本。 请注意,如果 fillEmptyCells 设置为 false,则此值会保留,并且设置此值不会将该属性设置为 true。 默认情况下,这是一个空字符串。

getEmptyCellText(): string;

返回

string

getEnableFieldList()

指定是否可以在 UI 中显示字段列表。

getEnableFieldList(): boolean;

返回

boolean

getFillEmptyCells()

指定是否应使用 填充数据透视表中的 emptyCellText空单元格。 默认值为 false。 请注意,当此属性设置为 false时,emptyCellText的值将保留。

getFillEmptyCells(): boolean;

返回

boolean

getFilterAxisRange()

返回数据透视表筛选区的区域。

getFilterAxisRange(): Range;

返回

getLayoutType()

此属性指示数据透视表上的所有字段的 PivotLayoutType。 如果字段状态不同,则为 null。

getLayoutType(): PivotLayoutType;

返回

getPreserveFormatting()

指定在通过透视、排序或更改页字段项等作刷新或重新计算报表时是否保留格式。

getPreserveFormatting(): boolean;

返回

boolean

getRange()

返回存在数据透视表的区域,不包括筛选区。

getRange(): Range;

返回

getRowLabelRange()

返回数据透视表行标签所在位置的区域。

getRowLabelRange(): Range;

返回

getShowColumnGrandTotals()

指定数据透视表是否显示列的总计。

getShowColumnGrandTotals(): boolean;

返回

boolean

getShowFieldHeaders()

指定数据透视表是否) 显示字段标题 (字段标题和筛选器下拉列表。

getShowFieldHeaders(): boolean;

返回

boolean

getShowRowGrandTotals()

指定数据透视表是否显示行的总计。

getShowRowGrandTotals(): boolean;

返回

boolean

getSubtotalLocation()

此属性指示 SubtotalLocationType 数据透视表上所有字段的 。 如果字段具有不同的状态,则为 null

getSubtotalLocation(): SubtotalLocationType;

返回

repeatAllItemLabels(repeatLabels)

设置数据透视表中所有字段的“重复所有项目标签”设置。

repeatAllItemLabels(repeatLabels: boolean): void;

参数

repeatLabels

boolean

如果为 True,则会打开标签重复显示设置。 False 会将其关闭。

返回

void

setAltTextDescription(altTextDescription)

数据透视表的替换文字说明。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

setAltTextDescription(altTextDescription: string): void;

参数

altTextDescription

string

返回

void

setAltTextTitle(altTextTitle)

数据透视表的替换文字标题。

替换文字提供数据透视表中包含的信息的基于文本的替代表示形式。 此信息对于可能无法看到或理解表格的视力或认知障碍人士非常有用。 游戏可以读给残障人士,并用于确定是否要听到内容的说明。

setAltTextTitle(altTextTitle: string): void;

参数

altTextTitle

string

返回

void

setAutoFormat(autoFormat)

指定在刷新时还是移动字段时自动设置格式设置格式。

setAutoFormat(autoFormat: boolean): void;

参数

autoFormat

boolean

返回

void

setAutoSortOnCell(cell, sortBy)

将数据透视表设置为使用指定的单元格设置自动排序,以自动选择排序的所有条件和上下文。 这与从 UI 应用自动排序的行为相同。

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

参数

cell

ExcelScript.Range | string

一个单元格,用于获取用于应用自动排序的条件。

sortBy
ExcelScript.SortBy

排序的方向。

返回

void

setEmptyCellText(emptyCellText)

如果 fillEmptyCells == true,则自动填充到数据透视表中的任何空单元格中的文本。 请注意,如果 fillEmptyCells 设置为 false,则此值会保留,并且设置此值不会将该属性设置为 true。 默认情况下,这是一个空字符串。

setEmptyCellText(emptyCellText: string): void;

参数

emptyCellText

string

返回

void

setEnableFieldList(enableFieldList)

指定是否可以在 UI 中显示字段列表。

setEnableFieldList(enableFieldList: boolean): void;

参数

enableFieldList

boolean

返回

void

setFillEmptyCells(fillEmptyCells)

指定是否应使用 填充数据透视表中的 emptyCellText空单元格。 默认值为 false。 请注意,当此属性设置为 false时,emptyCellText的值将保留。

setFillEmptyCells(fillEmptyCells: boolean): void;

参数

fillEmptyCells

boolean

返回

void

setLayoutType(layoutType)

此属性指示数据透视表上的所有字段的 PivotLayoutType。 如果字段状态不同,则为 null。

setLayoutType(layoutType: PivotLayoutType): void;

参数

返回

void

示例

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

setPreserveFormatting(preserveFormatting)

指定在通过透视、排序或更改页字段项等作刷新或重新计算报表时是否保留格式。

setPreserveFormatting(preserveFormatting: boolean): void;

参数

preserveFormatting

boolean

返回

void

setShowColumnGrandTotals(showColumnGrandTotals)

指定数据透视表是否显示列的总计。

setShowColumnGrandTotals(showColumnGrandTotals: boolean): void;

参数

showColumnGrandTotals

boolean

返回

void

setShowFieldHeaders(showFieldHeaders)

指定数据透视表是否) 显示字段标题 (字段标题和筛选器下拉列表。

setShowFieldHeaders(showFieldHeaders: boolean): void;

参数

showFieldHeaders

boolean

返回

void

setShowRowGrandTotals(showRowGrandTotals)

指定数据透视表是否显示行的总计。

setShowRowGrandTotals(showRowGrandTotals: boolean): void;

参数

showRowGrandTotals

boolean

返回

void

setSubtotalLocation(subtotalLocation)

此属性指示 SubtotalLocationType 数据透视表上所有字段的 。 如果字段具有不同的状态,则为 null

setSubtotalLocation(subtotalLocation: SubtotalLocationType): void;

参数

返回

void

示例

/**
 * This script displays group subtotals of the "Farms Sales" PivotTable.
 */
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();

  // Show all the subtotals at the bottom of each group.
  layout.setSubtotalLocation(ExcelScript.SubtotalLocationType.atBottom);
}