How to Remove Pivot Table using Java

This is a brief tutorial to explain how to remove pivot table using Java. You will get all the necessary details to set the development environment, a list of tasks depicting the programming logic, and a runnable sample code showing how to delete pivot table using Java. This sample code can be executed in any of the Java-supported platforms and does not require any third-party tool to eliminate the pivot tables from an Excel file.

Steps to Delete Pivot Table using Java

  1. Add Aspose.Cells library from the Maven Repository to remove a pivot table
  2. Load the workbook with pivot tables in it
  3. Access the target worksheet where the pivot table is available
  4. Call the removeAt() method in the PivotTableCollection object in the worksheet
  5. Save the workbook with deleted pivot table

These steps summarize the process of how to remove the pivot table in Excel using Java. The process is commenced by loading the Excel file followed by accessing the target sheet where pivot tables and relevant data is present. Based upon the target pivot table position in the collection, the removeAt() method is called to delete the pivot table before saving the Excel file on the disk.

Code to Remove Pivot Table using Java

This sample code has demonstrated how to delete pivot table in Excel using Java. In this sample, we have used the pivot table index to delete it from the collection. However, if you have a reference to the PivotTable object in the collection, you may use the remove() method by providing the target pivot table object for deleting it.

This brief tutorial has guided us on how to remove pivot table in Excel using Java. If you want to remove all a comment from an Excel file, refer to the article on how to insert comment in Excel using Java.

 English