删除枢轴连接

可能的使用场景

如果要在 Excel 中取消关联切片器和数据透视表,您需要右键单击切片器并选择“报告连接…”项。在选项列表中,您可以对复选框进行操作。同样,如果您想以编程方式使用 Aspose.Cells API 取消切片器和数据透视表的关联,请使用[Slicer.removePivotConnection(数据透视表枢轴)](https://reference.aspose.com/cells/java/com.aspose.cells/slicer#removePivotConnection(com.aspose.cells.PivotTable)) 方法。它将解除切片器和数据透视表的关联。

删除切片器

下面的示例代码加载示例 Excel 文件包含一个现有的切片器。它访问切片器,然后解除切片器和数据透视表的关联。最后,它将工作簿另存为输出Excel文件.

示例代码

// Load sample Excel file containing slicer.
Workbook wb = new Workbook("remove-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);
//Remove PivotTable connection.
slicer.removePivotConnection(pivottable);
// Save the workbook in output XLSX format.
wb.save("remove-pivot-connection-out.xlsx");