Insert Slicer

Possible Usage Scenarios

A slicer is used to filter data quickly. It can be used to filter data both in a table and a pivot table. Microsoft Excel allows you to create a slicer by selecting a table or pivot table and then clicking Insert > Slicer. Aspose.Cells also allows you to create a slicer using the Worksheet.Slicers.Add() method.

Create a Slicer for a Pivot Table

Please see the following sample code. It loads the sample Excel file that contains the pivot table. It then creates the slicer based on the first base pivot field. Finally, it saves the workbook in output XLSX and output XLSB format. The following screenshot shows the slicer created by Aspose.Cells in the output Excel file.

todo:image_alt_text

Sample Code

Create a Slicer for an Excel Table

Please see the following sample code. It loads the sample Excel file that contains a table. It then creates the slicer based on the first column. Finally, it saves the workbook in output XLSX format.

Sample Code

Advanced topics

  • Change Slicer Properties
  • Draw Slicer while rendering Excel to PDF
  • Formatting Slicer
  • Removing Slicer
  • Rendering Slicer
  • Updating Slicer