Disable Pivot Table Ribbons
Contents
[
Hide
]
Pivot table based reports are useful but prone to error if target users do not have detailed knowledge of Excel to configure these reports. In these circumstances, organizations will want to restrict users from being able to change a pivot table based report. Common pivot table features like adding additional filters, slicers, fields, or changing the order of certain things in the report are mostly not recommended for every user. On the other hand, these users shall also be able to refresh the report and use existing filters or slicers. Aspose.Cells has provided this ability to developers for restricting users from changing these reports while creating these reports. For this purpose, Excel provides a feature to disable the pivot table ribbon and the same is provided by Aspose.Cells i.e. developer can disable the ribbon which contains controls to modify these reports.
Disable Pivot Table Ribbon using PivotTable.setEnableWizard
Following code demonstrates this feature by accessing a pivot table from a sheet and then calling the setEnableWizard to set this flag false. Sample pivot table file can be downloaded from this link.
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-Java | |
// Open the template file containing the pivot table | |
Workbook wb = new Workbook("pivot_table_test.xlsx"); | |
// Access the pivot table in the first sheet | |
PivotTable pt = wb.getWorksheets().get(0).getPivotTables().get(0); | |
// Disable ribbon for this pivot table | |
pt.setEnableWizard(false); | |
// Save output file | |
wb.save("out_java.xlsx"); |