How to show pivot table data field values vertically in case of multiple data fields?


Please find the attached Actual and Expected workbooks for this use case.

In the Actual workbook, it is possible to change the layout by dragging/moving the Values field out of Column Lables area to Row Lables area. However, I don't know how to achieve the same functionality in Aspose. Can you help me do the same with Aspose Cells.


See the following lines of code that you can embed to your code for your requirements for your reference:
Sample code:

Workbook workbook = new Workbook(“Actual.xlsx”);

PivotTable pivotTable = workbook.getWorksheets().get(“Pivot Table”).getPivotTables().get(0);
//Get the second pivot column field
PivotField pivotField = pivotTable.getColumnFields().get(1);
//Drag to Row fields area
pivotTable.addFieldToArea(PivotFieldType.ROW, pivotField);
//Caculate Pivot data to implement the new change

Hope, this helps a bit.

Thank you.