ワークシートからのピボットテーブルの削除
Contents
[
Hide
]
Aspose.Cellsでは、ワークシートからピボットテーブルを削除する機能が提供されています。ピボットテーブルオブジェクトやピボットテーブルの位置を使用して削除できます。
次のサンプルコードでは、ワークシートから2つのピボットテーブルを削除する方法が示されています。最初にWorksheet.PivotTables.Remove()メソッドを使用してピボットテーブルを削除し、次にWorksheet.PivotTables.RemoveAt()メソッドを使用してピボットテーブルを削除します。
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object from source Excel file | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access the first pivot table object | |
PivotTable pivotTable = worksheet.PivotTables[0]; | |
// Remove pivot table using pivot table object | |
worksheet.PivotTables.Remove(pivotTable); | |
// OR you can remove pivot table using pivot table position by uncommenting below line | |
//worksheet.PivotTables.RemoveAt(0); | |
// Save the workbook | |
workbook.Save(dataDir + "output_out.xlsx"); |