# Add-OfficeExcelSlicer

Adds slicer or timeline binding metadata for a pivot table or table.

Cmdlet 

Aliases: ExcelSlicer

**Module**

`PSWriteOffice`

**Aliases**

`ExcelSlicer`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[AddOfficeExcelSlicerCommand.cs:30](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/AddOfficeExcelSlicerCommand.cs#L30) 

Adds slicer or timeline binding metadata for a pivot table or table.

## Syntax

```
Add-OfficeExcelSlicer
[-Document <ExcelDocument>]
-Name <String>
[-PassThru]
[-PivotTable <String>]
[-SourceName <String>]
[-Timeline]
[-Xml <String>]
[<CommonParameters>]
```

[#](#method-add-officeexcelslicer-exceldocument-string-switchparameter-string-string-switchparameter-string)

Parameter set: `Default`

## Examples

### Add a slicer for a pivot field

```powershell
Open-OfficeExcel -Path .\Reports\Sales-2026.xlsx {
    ExcelSlicer -Name RegionSlicer -SourceName Region -PivotTable SalesPivot
}
```

Adds slicer metadata for the Region field of the SalesPivot pivot table.

### Add a timeline for order dates

```powershell
Open-OfficeExcel -Path .\Reports\Sales-2026.xlsx {
    ExcelSlicer -Name OrderDateTimeline -SourceName OrderDate -PivotTable SalesPivot -Timeline
}
```

Adds timeline metadata for the OrderDate field so readers can filter the pivot table by period in Excel.

## Parameters

**-Document ExcelDocument optionalpipeline: True (ByValue)**

Caller-owned workbook; omission uses the enclosing Excel content block.

**-Name String required**

Slicer cache name.

**-PassThru SwitchParameter optional**

Emits the native result after the operation.

**-PivotTable String optional**

Native pivot table whose data or entire range is targeted.

**-SourceName String optional**

Source field, table column, or pivot field name.

**-Timeline SwitchParameter optional**

Creates timeline metadata instead of a standard slicer.

**-Xml String optional**

Caller-supplied slicer cache XML. When provided, OfficeIMO preserves it within its pivot-interaction metadata envelope.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:F9FE7561BAF424236F4ED74F601068ED18DB2E538736A9F028D06AD49D6931C6 -->
