from aspose.cells import PrintOrderType, Workbook

#  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]
#  Setting the PivotTable report shows grand totals for rows.
pivotTable.row_grand = True
#  Setting the PivotTable report shows grand totals for columns.
pivotTable.column_grand = True
#  Setting the PivotTable report displays a custom string in cells that contain null values.
pivotTable.display_null_string = True
pivotTable.null_string = "null"
#  Setting the PivotTable report's layout
pivotTable.page_field_order = PrintOrderType.DOWN_THEN_OVER
#  Saving the Excel file
workbook.save(dataDir + "output.xls")