移除切片器

可能的使用场景

如果要在Microsoft Excel中移除切片器,只需选择它并按下Delete按钮。同样,如果要使用Aspose.Cells API编程方式移除它,请使用Worksheet.Slicers.Remove()方法。这将从工作表中移除切片器。

移除切片器

以下示例代码加载了包含现有切片器的sample Excel file。它访问切片器,然后将其移除,最后将工作簿保存为output Excel file。以下截图展示了在执行示例代码后将要移除的切片器。

todo:image_alt_text

示例代码

// 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);