Removing Slicer

Possible Usage Scenarios

If you want to remove slicer in Microsoft Excel, just select it and press the Delete button. Similarly, if you want to remove it using Aspose.Cells for Python via .NET API programmatically, please use the Worksheet.slicers.remove() method. It will remove the slicer from the worksheet.

How to Remove Slicer Using Aspose.Cells for Python Excel Library

The following sample code loads the sample Excel file that contains an existing slicer. It accesses the slicers and then removes it. Finally, it saves the workbook as output Excel file. The following screenshot shows the slicer that will be removed after the execution of the sample code.

todo:image_alt_text

Sample Code

from aspose.cells import SaveFormat, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load sample Excel file containing slicer.
wb = Workbook("sampleRemovingSlicer.xlsx")
# Access first worksheet.
ws = wb.worksheets[0]
# Access the first slicer inside the slicer collection.
slicer = ws.slicers[0]
# Remove slicer.
ws.slicers.remove(slicer)
# Save the workbook in output XLSX format.
wb.save("outputRemovingSlicer.xlsx", SaveFormat.XLSX)