from aspose.cells import Workbook from aspose.cells.pivot import PivotFieldDataDisplayFormat, PivotItemPosition # For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET # The path to the documents directory. dataDir = RunExamples.GetDataDir(".") # Load a template file workbook = Workbook(dataDir + "Book1.xls") # Get the first worksheet worksheet = workbook.worksheets[0] pivotindex = 0 # Accessing the PivotTable pivotTable = worksheet.pivot_tables[pivotindex] # Accessing the data fields. pivotFields = pivotTable.data_fields # Accessing the first data field in the data fields. pivotField = pivotFields[0] # Setting data display format pivotField.data_display_format = PivotFieldDataDisplayFormat.PERCENTAGE_OF # Setting the base field. pivotField.base_field_index = 1 # Setting the base item. pivotField.base_item_position = PivotItemPosition.NEXT # Setting number format pivotField.number = 10 # Saving the Excel file workbook.save(dataDir + "output.xls")