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

Hi,

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.

Hi,


See the following lines of code that you can embed to your code for your requirements for your reference:
e.g
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
pivotTable.calculateData();
workbook.save(“out1.xlsx”);

Hope, this helps a bit.

Thank you.