Remove Pivot Connection
Possible Usage Scenarios
If you want to disassociate slicer and pivot table in Excel, you need to right-click slicer and select “Report Connections…” item. In the option list, you can operate on the check box. Similarly, if you want to disassociate slicer and pivot table using Aspose.Cells for Python via .NET API programmatically, please use the Slicer.remove_pivot_connection(pivot) method. It will disassociate slicer and pivot table.
How to Disassociate Slicer and Pivot Table Using Aspose.Cells for Python Excel library
The following sample code loads the sample Excel file that contains an existing slicer. It accesses the slicers and then disassociates slicer and pivot table. Finally, it saves the workbook as output Excel file.
Sample Code
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") |