从工作表中删除数据透视表
Contents
[
Hide
]
Aspose.Cells for Node.js via C++ 提供了从工作表中删除或移除数据透视表的功能。你可以使用数据透视表对象或其位置来删除数据透视表。请使用 Worksheet.getPivotTables().remove(pivotTable) 方法通过数据透视表对象删除,使用 Worksheet.getPivotTables().removeAt(index, keepData) 方法通过其在数据透视表集合中的位置删除。
如何使用 Aspose.Cells for Node.js via C++ 从工作表中删除数据透视表
以下示例代码从工作表中删除了两个数据透视表。首先使用Worksheet.getPivotTables().remove(pivotTable)方法移除数据透视表,然后使用Worksheet.getPivotTables().removeAt(index, keepData)方法移除数据透视表。
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"); |