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 API programmatically, please use the Worksheet.Slicers.Remove() method. It will remove the slicer from the worksheet.
Removing Slicer
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.
Sample Code
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Load sample Excel file containing slicer. | |
Workbook wb = new Workbook("sampleRemovingSlicer.xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
// Access the first slicer inside the slicer collection. | |
Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[0]; | |
// Remove slicer. | |
ws.Slicers.Remove(slicer); | |
// Save the workbook in output XLSX format. | |
wb.Save("outputRemovingSlicer.xlsx", SaveFormat.Xlsx); |