移除切片器
Contents
[
Hide
]
可能的使用场景
如果想在 Microsoft Excel 中删除切片器,只需选择它并按[删除]键。同样,如果希望通过 Aspose.Cells API 编程删除,可以使用 Worksheet.getSlicers().remove() 方法。它会从工作表中移除切片器。
移除切片器
以下示例代码加载包含现有分析器的 示例 Excel 文件。访问分析器,然后移除它。最后,将工作簿另存为 输出 Excel 文件。截图显示示例代码执行后将要移除的分析器。
示例代码
This file contains hidden or 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-Java | |
// Load sample Excel file containing slicer. | |
Workbook wb = new Workbook(srcDir + "sampleRemovingSlicer.xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Access the first slicer inside the slicer collection. | |
Slicer slicer = ws.getSlicers().get(0); | |
// Remove slicer. | |
ws.getSlicers().remove(slicer); | |
// Save the workbook in output XLSX format. | |
wb.save(outDir + "outputRemovingSlicer.xlsx", SaveFormat.XLSX); |