删除数据透视连接

可能的使用场景

如果要在Excel中取消切片器与数据透视表的关联,您需要右键单击切片器并选择"Report Connections…“选项。在选项列表中,您可以操作复选框。同样,如果要使用Aspose.Cells API编程方式取消切片器与数据透视表的关联,请使用Slicer.RemovePivotConnection(PivotTable pivot)方法。这将取消切片器与数据透视表的关联。

取消切片器与数据透视表的关联

以下示例代码加载了包含现有切片器的sample Excel file。它访问切片器,然后取消切片器与数据透视表的关联,最后将工作簿保存为output Excel file

示例代码

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