ピボット接続を解除する

可能な使用シナリオ

Microsoft Excelでスライサーとピボットテーブルを非連携にしたい場合は、スライサーを右クリックし、「レポートの接続…」アイテムを選択する必要があります。オプションリストでチェックボックスを操作できます。同様に、Aspose.Cells APIを使用してスライサーとピボットテーブルを非連携にしたい場合は、Slicer.RemovePivotConnection(PivotTable pivot) メソッドを使用してください。これにより、スライサーとピボットテーブルが非連携になります。

スライサーとピボットテーブルの非連携

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

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Load sample Excel file containing slicer.
Workbook wb = new Workbook("remove-pivot-connection.xlsx");
// Access first worksheet.
Worksheet ws = wb.Worksheets[0];
// Access the first PivotTable inside the PivotTable collection.
PivotTable pivottable = ws.PivotTables[0];
// Access the first slicer inside the slicer collection.
Slicer slicer = ws.Slicers[0];
//Remove PivotTable connection.
slicer.RemovePivotConnection(pivottable);
// Save the workbook in output XLSX format.
wb.Save("remove-pivot-connection-out.xlsx");