删除切片器
Contents
[
Hide
]
可能的使用场景
如果要删除 Microsoft Excel 中的切片器,只需选择它并按删除按钮。同样,如果您想以编程方式使用 Aspose.Cells API 将其删除,请使用工作表.Slicers.Remove()方法。它将从工作表中删除切片器。
删除切片器
下面的示例代码加载示例 Excel 文件包含一个现有的切片器。它访问切片器然后将其删除。最后,它将工作簿另存为输出Excel文件.以下屏幕截图显示了在执行示例代码后将被删除的切片器。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |