移除切片器
Contents
[
Hide
]
可能的使用场景
如果您要在 Microsoft Excel 中移除数据透视表筛选器,只需选择它,然后按删除按钮。同样,如果您要使用 Aspose.Cells for Python via .NET API 在程序中移除它,请使用 Worksheet.slicers.remove() 方法。它将从工作表中删除数据透视表筛选器。
如何使用 Aspose.Cells for Python Excel 库移除数据透视表筛选器
以下示例代码加载了包含现有切片器的sample Excel file。它访问切片器,然后将其移除,最后将工作簿保存为output Excel file。以下截图展示了在执行示例代码后将要移除的切片器。
示例代码
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
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Load sample Excel file containing slicer. | |
wb = Workbook("sampleRemovingSlicer.xlsx") | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Access the first slicer inside the slicer collection. | |
slicer = ws.slicers[0] | |
# Remove slicer. | |
ws.slicers.remove(slicer) | |
# Save the workbook in output XLSX format. | |
wb.save("outputRemovingSlicer.xlsx", SaveFormat.XLSX) |