We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Question on Pivot refresh using Java

i am unable to do pivot refresh, i used the code Workbook workbook = new Workbook(templateFilePath);
	//Get the first worksheet
	Worksheet sheet =null;
		for(int i=0;i<=workbook.getWorksheets().getCount();i++)
		{
			sheet = workbook.getWorksheets().get(i);
			//Get the pivot tables in the sheet
			PivotTableCollection pivotTables = sheet.getPivotTables();

			//Get the first PivotTable
			PivotTable pivotTable = pivotTables.get(i);

			
		
			//Set the refresh data flag on
			pivotTable.setRefreshDataFlag(false);

			//Refresh and calculate the pivot table data
			pivotTable.refreshData();
			pivotTable.calculateData();

		}

	//Save the Excel file
	
	workbook.save(templateFilePath);

and getting the error

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.aspose.cells.PivotTableCollection.get(Unknown Source)
at com.steelwedge.reportapplet.ReportApplet.mergeAndOpenTemplate(ReportApplet.java:162)
at com.steelwedge.reportapplet.ReportRunnable$1$1.run(ReportRunnable.java:137)


Hi,

Thanks for your posting and using Aspose.Cells.

Please download and try the latest version: Aspose.Cells
for Java v8.0.0.2
it should fix your issue.

If it still throws exception, then please provide us your template file containing the pivot table throwing this exception. We will look into it and help you asap.