Removing Slicer

Removing Slicer

To remove slicer in Microsoft Excel, you simply select the slicer and press the Delete button. To achieve the save using Aspose.Cells for Python via Java, use the Worksheet.getSlicers().remove() method. It will remove the slicer from the worksheet. 

The following code snippet loads the sample Excel file that contains an existing slicer. It accesses the slicer, removes it, and saves the output Excel file. The following screenshot shows the slicer that will be removed.

todo:image_alt_text

Sample Code

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, SaveFormat
# Load Source Excel file
workbook = Workbook("sampleRemovingSlicer.xlsx")
# Access first worksheet
worksheet = workbook.getWorksheets().get(0)
# Access the newly added slicer from slicer collection
slicer = worksheet.getSlicers().get(0)
# Remove slicer
worksheet.getSlicers().remove(slicer)
# Save the workbook in output XLSX format
workbook.save("outputRemovingSlicer.xlsx", SaveFormat.XLSX)
jpype.shutdownJVM()