I’m using Aspose.Cells to create a PivotTable and need the data and row filters to be sorted. Despite using the code below, the generated Excel file doesn’t apply the sorting. Could anyone provide guidance on how to resolve this?
// Draging the field to the row area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, 3);
// Draging the field to the column area.
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Column, 0);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Data, 4);
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Page, 1);
// Access the Page field (Region) and set the sort order
PivotField pageField = pivotTable.PageFields[0];
pageField.IsAscendSort = true; // Sort in ascending order
// Access the Row field (Product) and set the sort order
PivotField rowField = pivotTable.RowFields[0];
rowField.IsAscendSort = true; // Sort in ascending order
image.png (47.1 KB)
MyExported0815-sample2filters.zip (3.4 MB)