How to change data source of existing pivot table. main purpose of this code is to update the data source of pivot table because if no. of rows of data is increased then it would won’t come in the pivot table so that’s why i have to change the data source of pivot table again and as the data source is updated.
actually below is my code please check and give me your suggestions.
path = r"E:\sample\Pivot1.xlsx"
path2 = r"E:\sample\Pivot2.xlsx"
wb = Workbook(path)
ws = wb.getWorksheets()
sheet_ds = wb.getWorksheets().get(0)
sheet_pt = wb.getWorksheets().get(1)
pts = sheet_pt.getPivotTables().get(0)
sheet_ds_range = sheet_ds.getCells().getMaxDisplayRange().getRefersTo()
so i am using above code but i am getting error of java exception and error is “com.aspose.cells.CellsException: The PivotTable field name is invalid.”
and i am getting error on refreshData() so if you can help me with this, that what i am doing wrong it will be great.