API Reference
Command
Add-OfficeExcelPivotTable
Adds a pivot table to a worksheet.
Remarks
Adds a pivot table to a worksheet.
Examples
Create a basic pivot table.
PS>Add-OfficeExcelPivotTable -SourceRange 'A1:D200' -DestinationCell 'F2' -RowField 'Region' -DataField 'Sales'
Creates a pivot table in F2 using Region as rows and Sales as the data field.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Add-OfficeExcelPivotTable [-ColumnField <String[]>] [-DataField <String[]>] [-DataFunction <String[]>] [-DataOnColumns] [-DataOnRows] -DestinationCell <String> [-HideDrill] [-HideEmptyColumns] [-HideEmptyRows] [-HideHeaders] [-Layout <String>] [-Name <String>] [-NoColumnGrandTotals] [-NoRowGrandTotals] [-PageField <String[]>] [-PassThru] [-PivotStyle <String>] [-RowField <String[]>] [-ShowDrill] [-ShowEmptyColumns] [-ShowEmptyRows] [-ShowHeaders] -SourceRange <String> [<CommonParameters>]#Parameter set:
ContextParameters
- ColumnField String[]
- Column fields (header names).
- DataField String[]
- Data fields (header names). Defaults to the last column when omitted.
- DataFunction String[]
- Aggregation functions (Sum, Count, Average, etc.).
- DataOnColumns SwitchParameter
- Show data fields on columns.
- DataOnRows SwitchParameter
- Show data fields on rows.
- DestinationCell String
- Top-left destination cell for the pivot table (e.g., "F2").
- HideDrill SwitchParameter
- Hide drill indicators.
- HideEmptyColumns SwitchParameter
- Hide empty columns.
- HideEmptyRows SwitchParameter
- Hide empty rows.
- HideHeaders SwitchParameter
- Hide field headers.
- Layout String
- Pivot layout (Compact, Outline, Tabular).
- Name String
- Optional pivot table name.
- NoColumnGrandTotals SwitchParameter
- Disable column grand totals.
- NoRowGrandTotals SwitchParameter
- Disable row grand totals.
- PageField String[]
- Page fields (header names) used as filters.
- PassThru SwitchParameter
- Emit the worksheet after creating the pivot table.
- PivotStyle String
- Optional pivot table style name.
- RowField String[]
- Row fields (header names).
- ShowDrill SwitchParameter
- Show drill indicators.
- ShowEmptyColumns SwitchParameter
- Show empty columns.
- ShowEmptyRows SwitchParameter
- Show empty rows.
- ShowHeaders SwitchParameter
- Show field headers.
- SourceRange String
- Source data range including header row (e.g., "A1:D200").
Outputs
System.Object
Add-OfficeExcelPivotTable [-ColumnField <String[]>] [-DataField <String[]>] [-DataFunction <String[]>] [-DataOnColumns] [-DataOnRows] -DestinationCell <String> -Document <ExcelDocument> [-HideDrill] [-HideEmptyColumns] [-HideEmptyRows] [-HideHeaders] [-Layout <String>] [-Name <String>] [-NoColumnGrandTotals] [-NoRowGrandTotals] [-PageField <String[]>] [-PassThru] [-PivotStyle <String>] [-RowField <String[]>] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-ShowDrill] [-ShowEmptyColumns] [-ShowEmptyRows] [-ShowHeaders] -SourceRange <String> [<CommonParameters>]#Parameter set:
DocumentParameters
- ColumnField String[]
- Column fields (header names).
- DataField String[]
- Data fields (header names). Defaults to the last column when omitted.
- DataFunction String[]
- Aggregation functions (Sum, Count, Average, etc.).
- DataOnColumns SwitchParameter
- Show data fields on columns.
- DataOnRows SwitchParameter
- Show data fields on rows.
- DestinationCell String
- Top-left destination cell for the pivot table (e.g., "F2").
- Document ExcelDocument
- Workbook to operate on outside the DSL context.
- HideDrill SwitchParameter
- Hide drill indicators.
- HideEmptyColumns SwitchParameter
- Hide empty columns.
- HideEmptyRows SwitchParameter
- Hide empty rows.
- HideHeaders SwitchParameter
- Hide field headers.
- Layout String
- Pivot layout (Compact, Outline, Tabular).
- Name String
- Optional pivot table name.
- NoColumnGrandTotals SwitchParameter
- Disable column grand totals.
- NoRowGrandTotals SwitchParameter
- Disable row grand totals.
- PageField String[]
- Page fields (header names) used as filters.
- PassThru SwitchParameter
- Emit the worksheet after creating the pivot table.
- PivotStyle String
- Optional pivot table style name.
- RowField String[]
- Row fields (header names).
- Sheet String
- Worksheet name when using Document.
- SheetIndex Nullable`1
- Worksheet index (0-based) when using Document.
- ShowDrill SwitchParameter
- Show drill indicators.
- ShowEmptyColumns SwitchParameter
- Show empty columns.
- ShowEmptyRows SwitchParameter
- Show empty rows.
- ShowHeaders SwitchParameter
- Show field headers.
- SourceRange String
- Source data range including header row (e.g., "A1:D200").
Outputs
System.Object