删除数据透视连接
Contents
[
Hide
]
可能的使用场景
如果您要在 Excel 中取消关联数据透视表筛选器和数据透视表,您需要右键单击筛选器,然后选择"报表连接…“项。在选项列表中,您可以操作复选框。同样,如果您要使用 Aspose.Cells for Python via .NET API 在程序中取消关联数据透视表筛选器和数据透视表,请使用 Slicer.remove_pivot_connection(pivot) 方法。它会取消关联数据透视表筛选器和数据透视表。
如何使用 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 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("remove-pivot-connection.xlsx") | |
# Access first worksheet. | |
ws = wb.worksheets[0] | |
# Access the first PivotTable inside the PivotTable collection. | |
pivottable = ws.pivot_tables[0] | |
# Access the first slicer inside the slicer collection. | |
slicer = ws.slicers[0] | |
# Remove PivotTable connection. | |
slicer.remove_pivot_connection(pivottable) | |
# Save the workbook in output XLSX format. | |
wb.save("remove-pivot-connection-out.xlsx") |