删除枢轴连接

可能的使用场景

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

分离切片器和数据透视表

下面的示例代码加载示例 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");