ピボット接続を解除する

可能な使用シナリオ

Excelでスライサとピボットテーブルを関連付けを解除したい場合は、スライサを右クリックし、「レポートの接続…」項目を選択する必要があります。オプションリストでチェックボックスで操作できます。同様に、Aspose.Cells for Python via .NET APIを使用してプログラム的にスライサとピボットテーブルを関連付けを解除したい場合は、Slicer.remove_pivot_connection(pivot)メソッドを使用してください。これにより、スライサとピボットテーブルが関連付けを解除します。

Aspose.Cells for PythonのExcelライブラリを使用して、スライサーとピボットテーブルを切り離す方法

次のサンプルコードは、既存のスライサーを含む サンプルExcelファイル を読み込みます。それからスライサーにアクセスして非連携にします。最後に、ワークブックを出力Excelファイルとして保存します。

サンプルコード

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")