Ta bort pivottabell från ett arbetsblad
Contents
[
Hide
]
Aspose.Cells for Node.js via C++ tillhandahåller en funktion för att ta bort eller radera pivot-tabell från ett kalkylblad. Du kan ta bort pivot-tabellen med hjälp av pivot-tabell-objektet eller dess position. Använd Worksheet.getPivotTables().remove(pivotTable)-metoden för att ta bort pivot-tabellen med pivot-tabell-objekt och Worksheet.getPivotTables().removeAt(index, keepData)-metoden för att ta bort pivot-tabell-objektet med dess position inom pivot-tabellssamlingen.
Hur man tar bort pivot-tabell från kalkylblad med Aspose.Cells for Node.js via C++
Följande kodexempel tar bort två pivottabeller från arbetsbladet. Först tar det bort pivottabellen med hjälp av Worksheet.getPivotTables().remove(pivotTable) -metoden och sedan tar det bort pivottabellen med hjälp av Worksheet.getPivotTables().removeAt(index, keepData) -metoden
This file contains hidden or 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
const AsposeCells = require("aspose.cells.node"); | |
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
var dataDir = RunExamples.GetDataDir("."); | |
// Create workbook object from source Excel file | |
var workbook = new AsposeCells.Workbook(dataDir + "source.xlsx"); | |
// Access the first worksheet | |
var worksheet = workbook.getWorksheets().get(0); | |
// Access the first pivot table object | |
var pivotTable = worksheet.getPivotTables().get(0); | |
// Remove pivot table using pivot table object | |
worksheet.getPivotTables().remove(pivotTable); | |
// OR you can remove pivot table using pivot table position by uncommenting below line | |
//worksheet.getPivotTables().removeAt(0); | |
// Save the workbook | |
workbook.save(dataDir + "output_out.xlsx"); |