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

Free Support Forum - aspose.com

Need to remove auto generated count values from pivot table

Hello,

I just want sum to be present in the pivot table however when I do:
pivotTable.refreshData();
pivotTable.calculateData();

It always generates Count as well. Please review, this is for aspose cells Java.

Best Regards,
Amit

@amitkumartrips,

Thanks for providing us some details.

Well, you need to specify the function/subtotal as Sum for the pivot field explicitly, see the following sample code segment for your reference:
e.g
Sample code:

 ........
 //Set the consolidation function for the first data field to SUM, you can set it to Average, Count, etc.
 pivotTable.getDataFields().get(0).setFunction(ConsolidationFunction.SUM);

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

If you still could not evaluate, kindly do provide sample code (runnable) and template file(s), we will check it soon.

I did the same:
PivotFieldCollection pivotFields = pivotTable.getDataFields();
PivotField pivotField = pivotFields.get(0);
pivotField.setFunction(ConsolidationFunction.SUM);

However for some reason count value still appears:
image.png (12.1 KB)

@amitkumartrips,

Thanks for the screenshot.

Well, you may call Chart.refreshPivotData() to get updated pivot chart:
e.g
Sample code:

.......
//Access pivot chart sheet and access chart and refresh its pivot data
Worksheet worksheet1 = workbook.getWorksheets().get(0);
Chart ch = ws.getCharts().get(0);
ch.refreshPivotData();

If you still could not evaluate, kindly do provide sample code (runnable) and template file(s), we will check it soon. Also provide a sample file containing your desired PivotChart in it, you may create/update the file manually in MS Excel.