Ta bort Pivot Connection
Contents
[
Hide
]
Möjliga användningsscenarier
Om du vill ta bort slicer- och pivottabellen i Excel måste du högerklicka på slicer och välja “Rapportera anslutningar…”. I alternativlistan kan du använda kryssrutan. På samma sätt, om du vill ta bort slicer- och pivottabellen med Aspose.Cells API programmatiskt, användSlicer.RemovePivotConnection(pivottabellspivot)metod. Det kommer att ta isär slicer och pivottabell.
Ta isär slicer- och pivottabellen
Följande exempelkod laddarexempel på Excel-filsom innehåller en befintlig skivare. Den får åtkomst till skivorna och kopplar sedan bort skivan och pivottabellen. Slutligen sparar den arbetsboken somutdata Excel-fil.
Exempelkod
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
// 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"); |