Lägg till Pivot Connection
Contents
[
Hide
]
Möjliga användningsscenarier
Om du vill associera slicer och pivottabell 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 associera slicer och pivottabell med Aspose.Cells API programmatiskt, användSlicer.AddPivotConnection(pivottabell)metod. Det kommer att associera slicer och pivottabell.
Associera Slicer och PivotTable
Följande exempelkod laddarexempel på Excel-filsom innehåller en befintlig skivare. Den får åtkomst till Slicer och associerar sedan Slicer och PivotTable. 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("add-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]; | |
//Adds PivotTable connection. | |
slicer.AddPivotConnection(pivottable); | |
wb.Save("add-pivot-connection-out.xlsx"); |