from aspose.cells import SheetType, Workbook from aspose.cells.charts import ChartType # 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(".") # Instantiating an Workbook object # Opening the excel file workbook = Workbook(dataDir + "pivotTable_test.xlsx") # Adding a new sheet sheet3 = workbook.worksheets[workbook.worksheets.add(SheetType.CHART)] # Naming the sheet sheet3.name = "PivotChart" # Adding a column chart index = sheet3.charts.add(ChartType.COLUMN, 0, 5, 28, 16) # Setting the pivot chart data source sheet3.charts[index].pivot_source = "PivotTable!PivotTable1" sheet3.charts[index].hide_pivot_field_buttons = False # Saving the Excel file workbook.save(dataDir + "pivotChart_test_out.xlsx")