Thanks for the template file.
We have evaluated your scenario/ case further. It looks the feature “Sort data in Data field with respect to / by Row pivot field in the PivotTable” is not supported at the moment as I tried the following sample code (I also tried with other options and combinations of the APIs) but it does not work as expected. It works fine if we sort the pivot field (Row field) itself.
Workbook wb = new Workbook(@“e:\test2\SortTest.xlsx”);
Worksheet wsData = wb.Worksheets;
Worksheet wsPivot = wb.Worksheets.Add(“pvt”);
PivotTableCollection pivotTables = wsPivot.PivotTables;
int index = pivotTables.Add("=‘Values’!A1:B3000", “A3”, “test_PivotTable”);
PivotTable pvtTable = pivotTables[index];
pvtTable.IsAutoFormat = true;
pvtTable.AutoFormatType = PivotTableAutoFormatType.Report4;
// add Hubsite row field
// add data field
int nDataField = pvtTable.AddFieldToArea(PivotFieldType.Data, “Count”);
pvtTable.DataFields[nDataField].Number = 3; // #,##0
pvtTable.RowFields.IsAutoSort = true;
pvtTable.RowFields.IsAscendSort = true;
//Sort by grand total (Sum of Count)
pvtTable.RowFields.AutoSortField = 1;
//Setting autoShow options.
//Setting the field auto show.
pvtTable.DataFields.IsAutoShow = true;
//Setting the field auto show ascend.
pvtTable.DataFields.IsAscendShow = true;
//Setting the auto show using field(data field).
pvtTable.DataFields.AutoShowField = 0;
// save & close file
I have logged a ticket with an id “CELLSNET-43257” for your issue/ requirements. We will look into it soon.
Once we have any update on it, we will let you know here.
And for your other needs i.e., change the header text in the Row header to “Hubsite”, well, when the Row label area only contains one PivotField, it would show “Row Label”. If you implement such a table in Ms Excel manually, you will get the same results too. You should first have the Row label area that contains two or more Pivot fields.