ワークシートからのピボットテーブルの削除

Aspose.Cells for Node.js via C++を使ったワークシートからのピボットテーブル削除方法

次のサンプルコードでは、ワークシートから2つのピボットテーブルを削除する方法が示されています。最初にWorksheet.getPivotTables().remove(pivotTable)メソッドを使用してピボットテーブルを削除し、次にWorksheet.getPivotTables().removeAt(index, keepData)メソッドを使用してピボットテーブルを削除します。

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