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

Free Support Forum - aspose.com

Subtract two pivot columns

Hi,

Please find attached a sample excel file. The sheet 1 has the data and sheet 2 contains the pivot table generated by aspose cells java code.

My requirement is to subtract the columns C and D in the pivot table present in sheet 2

Below is the code snippet which i used for pivot table :

pivotTable.addFieldToArea(PivotFieldType.ROW, 1);

pivotTable.addFieldToArea(PivotFieldType.COLUMN, 0);

pivotTable.addFieldToArea(PivotFieldType.DATA, 2);

Please provide a solution for my requirement.

Thanks,

Asha

Hi,


Thanks for the template file.

Well, I think you may try to use addCalculatedField method of PivotTable to implement your desired formula.
If you still could not evaluate, kindly do create the pivot table in MS Excel manually based on your data and add your desired formula in the pivot table report, save the file and attach it here, we will help you and tell you on how to do it with Aspose.Cells API.

And, see the sample line of code for reference:
pivotTable.addCalculatedField(“TestField”, “=Field1-Field2”, true);

Thank you.