ピボット接続を追加
Contents
[
Hide
]
考えられる使用シナリオ
Excel でスライサーとピボット テーブルを関連付けるには、スライサーを右クリックし、[接続のレポート] 項目を選択する必要があります。オプションリストでは、チェックボックスを操作できます。同様に、プログラムで Aspose.Cells Java API を使用してスライサーとピボット テーブルを関連付ける場合は、[Slicer.addPivotConnection(ピボットテーブル ピボット)](https://reference.aspose.com/cells/java/com.aspose.cells/slicer#addPivotConnection(com.aspose.cells.PivotTable)/) 方法。スライサーとピボット テーブルを関連付けます。
スライサーとピボットテーブルを関連付ける
次のサンプル コードは、サンプル Excel ファイル既存のスライサーが含まれています。スライサーにアクセスし、スライサーとピボットテーブルを関連付けます。最後に、ワークブックを次のように保存します。出力エクセルファイル.
サンプルコード
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
// Load sample Excel file containing slicer. | |
Workbook wb = new Workbook("add-pivot-connection .xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Access the first PivotTable inside the PivotTable collection. | |
PivotTable pivottable = ws.getPivotTables().get(0); | |
// Access the first slicer inside the slicer collection. | |
Slicer slicer = ws.getSlicers().get(0); | |
//Adds PivotTable connection. | |
slicer.addPivotConnection(pivottable); | |
wb.save("add-pivot-connection-out.xlsx"); |