移除切片器
Contents
[
Hide
]
可能的使用场景
如果您希望在 Microsoft Excel 中删除分析器,只需选择它并按下 删除 按钮。同样,如果要使用 Aspose.Cells API 在程序中删除它,请使用 Worksheet.getSlicers().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-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); |